我不知道這個問題是否仍然有趣,但我一直在使用這個插件很長一段時間,它實際上很容易使用。 幾乎所有的答案都可以在插件自帶的例子中找到,爲了解決您的問題,您可能需要查看以下用於使儀表板的當前佈局在服務器上保持不變的示例代碼。
請注意,「saveID」是保存按鈕的ID,「saveConfiguration」是將佈局保存在服務器上的URL。
// binding for saving the current configuration
$("#saveID").bind("click", function() {
var conf = $.parseJSON(dashboard.serialize()),
// get the serialized configuration
len = conf.data.length,
// generate the new parameter to submit
para = "lay=" + conf.layout + "&len=" + len,
i = 0;
for (i = 0; i < len; i += 1) {
para = para + "&pid" + i + "=" + conf.data[i].id + "&col" + i + "=" + conf.data[i].column;
}
// Invoke the "saveConfiguration" on the server via AJAX
$.ajax({
url: "saveConfiguration",
data: para,
dataType: "json",
success: function (jsonResponse) {
if (jsonResponse.valid === true) {
alert("Configuration has been saved");
} else {
alert("Error when trying to save the configuration\n" + jsonResponse.error);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert(textStatus + " - " + errorThrown);
}
});
return false;
});
你有沒有在這方面取得進展? – 2011-09-15 19:05:06