Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/412.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery便笺插件_Javascript_Jquery_Json_Jquery Plugins - Fatal编程技术网

Javascript jquery便笺插件

Javascript jquery便笺插件,javascript,jquery,json,jquery-plugins,Javascript,Jquery,Json,Jquery Plugins,我使用jQuery便笺插件 我使用asp.NETWeb服务和ajax将其与数据库连接,以创建注释、编辑和删除,然后使用json数组从数据库中获取注释。 问题是:我不能用数据库中的注释填充这个插件 它使用选项数组 jQuery(document).ready(function() { var options = { notes:[{"id":1, "text":"Test Internet Expl

我使用jQuery便笺插件 我使用asp.NETWeb服务和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行开始(您需要为
循环或其他内容放置
)。然后将数组分配给
选项。注意
如最后第二行所示

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);

你可以将你的代码粘贴到jqueryajax和示例json数组或webservice输出中。u r使用asp.net mvc 3?var Jnotes1=$.parseJSON(数据);var Jnotes2=JSON.stringify(数据)可以将Jnotes2的输出粘贴到这里吗?var Jnotes1=$.parseJSON(数据);var Jnotes2=JSON.stringify(data)你能在这里粘贴Jnotes2的输出吗?不要使用$.parseJSON(data.d);它适用于一维数组。如果使用jquery或ajax动态添加节点,效果会更好。
 $(documet).ready(function () {
            //calling for edit text      
            var edited = function (note) {
                alert("Edited note with id " + note.id + ", new text is: " + note.text);
            };
            // calling:create new note to add it to database
            var created = function (note) {
                alert("Created note with id " + note.id + ", text is: " + note.text);
            };

            //calling to delete note from database
            var deleted = function (note) {
                alert("Deleted note with id " + note.id + ", text is: " + note.text);
            };

            //calling to update location
            var moved = function (note) {
                alert("Moved note with id " + note.id + ", text is: " + note.text);
            };

            //calling to update size
            var resized = function (note) {
                alert("Resized note with id " + note.id + ", text is: " + note.text);
            };

            $.ajax({
                type: "POST",
                url: "../../Services/sticky_notes.asmx/getnotes",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function suc(data, status) {
                    var Jnotes = $.parseJSON(data);

                    //i have json now how can i use it to populate option
                    var options = {
                        notes: Jnotes,
                        resizable: true,
                        controls: true,
                        editCallback: edited,
                        createCallback: created,
                        deleteCallback: deleted,
                        moveCallback: moved,
                        resizeCallback: resized
                    };

                    $("#notes").stickyNotes(options);
                },
                error: function error(request, status, error) {
                    csscody.alert(request.statusText);
                }
            });
        });