$(this).sortable("serialize"); yields (an empty string)
I'm trying to save the state of the widgets upon adjusting them both
vertically or horizontally. When I use sortable("serialize") it yields
empty string. Where I'm going wrong?
My application opens a dialog box from where the widgets are selected. The
selected widgets are posted via ajax and the widgets appear properly but
upon adjusting them and using sortable("serialize") yields empty string.
Here is my code
$(function() {
$( ".column" ).sortable({
connectWith: ".column",
handle: ".portlet-header",
update : function(event, ui) {
var postData = $(this).sortable("serialize");
console.log(postData);
}
});
});
views.py
widgets_list = request.POST.getlist('widgets_list[]')
widget_header = ""
height = ""
content = ""
HTMLstr = ""
for widget in widgets_list:
if widget == "widget_liveGraph":
widget_header = "Live Graph"
content = ""
height = "270px"
elif widget == "widget_weather":
widget_header = "Weather"
content = "<script type='text/javascript'
src='http://voap.weather.com/weather/oap/INXX0012?template=GENXH&par=3000000007&unit=1&key=twciweatherwidget'></script>"
height = "auto"
elif widget == "widget_productivityEnergyUse":
widget_header = "Productivity Energy Use"
content = "<br><br> Per sq. feet :- <b>10
</b><br><br>" + \
"Per Occupants :- <b>1000</b>"
height = "auto"
elif widget == "widget_power":
widget_header = "Power"
content = "<br><br> <b>102</b> kW<br><br>"
height = "auto"
HTMLstr += "<div class='portlet ui-widget
ui-widget-content ui-helper-clearfix ui-corner-all'>"+ \
"<div class='portlet-header ui-widget-header
ui-corner-all'><span class='ui-icon
ui-icon-minusthick'>"+\
"</span>" + widget_header + "</div>" + \
"<div class='portlet-content' id="+ widget+"
style='height:"+ height + "; margin: 0 auto;'>" +
content + \
"</div></div>"
return HttpResponse(HTMLstr)
PS: I've also used the correct naming conventions in case of assigning
id's to the div elements , ie id = widget_productivityEnergyUse,
widget_power and so on.
Where I'm going wrong?
No comments:
Post a Comment