javascript - jquery 便签插件

标签 javascript jquery json jquery-plugins

我使用 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/

相关文章:

jquery - 为 pageX 将一个 div 分成两半

javascript - 如何更快、更智能地突出显示单词/术语?

javascript - JS如何向对象添加价格并通过参数传递

javascript - 根据链接点击更改 DIV 中的内容

javascript - JQuery 按顺序动画列表项然后淡出列表并重复

c# - 无法在 C# 中解析 JSON 响应

java - 使用 gson 解析 JSON 错误

ruby-on-rails-3 - 如何_知道_在我的 Rails 3 应用程序中哪个 JSON 渲染器处于事件状态?

javascript - 如何在表格行内重新定位表格单元格?

javascript - 以匀速圆周运动同时拖动元素