我使用 jQuery 粘滞便笺插件 http://www.jquery-sticky-notes.com/ 我使用 asp.net Web 服务和 ajax 将其与数据库连接以创建注释并编辑和删除,然后使用 json 数组从数据库获取注释。 问题是:我无法使用数据库中的注释填充此插件 它使用选项数组
jQuery(document).ready(function() {
var options = {
notes:[{"id":1,
"text":"Test Internet Explorer",
"pos_x": 50,
"pos_y": 50,
"width": 200,
"height": 200,
}]
,resizable: true
,controls: true
,editCallback: edited
,createCallback: created
,deleteCallback: deleted
,moveCallback: moved
,resizeCallback: resized
};
jQuery("#notes").stickyNotes(options);
});
如果现在有一个注释,则注释包含注释属性:- 我如何使用这组选项使用数据库中的注释填充此插件
最佳答案
尝试下面的代码,并根据代码中的注释填充 Note
数组,从第 3 行开始(您需要放置一个 For
循环或其他内容)。然后将数组分配给 option.notes
,如倒数第二行所示。
jQuery(document).ready(function() {
var note= new Object();
///////Populate the Notes array here
note=[{"id":1,
"text":"Sticky Text1",
"pos_x": 20,
"pos_y": 50,
"width": 200,
"height": 200,
},{"id":1,
"text":"Sticky Text 2",
"pos_x": 50,
"pos_y": 50,
"width": 200,
"height": 200,
}];
///////Populate the Notes array here
var options = {
notes:null
,resizable: true
,controls: true
,editCallback: edited
,createCallback: created
,deleteCallback: deleted
,moveCallback: moved
,resizeCallback: resized
};
options.notes=note;
jQuery("#notes").stickyNotes(options);
关于javascript - jquery 便签插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10497993/