neokoenig / jQuery-gridmanager

A way of building rows and grids with built in editable regions; requires jQuery, jQueryUI, Bootstrap 3.x, & optional TinyMCE or CKEditor
http://neokoenig.github.io/jQuery-gridmanager/
461 stars 129 forks source link

how to make it save able into file or database? #80

Closed onnosilaban closed 8 years ago

onnosilaban commented 8 years ago

hi masters, i'm a newbie, this is looks like a great script, but i don't have any idea to save it, is there any body can help me please?

neokoenig commented 8 years ago

You may find this useful - this example: https://gist.github.com/neokoenig/0112bf45d481283c8f9d takes the gridmanager contents and submits it via a form rather than ajax. I'm afraid I can't help you with the server side aspect as there's simply too many things to cover

ddegil commented 8 years ago

I came upon a better method to do the above. In my save function I get the gridmaster data this way now:

                // We need the canvas in edit more
                if ($('.gm-edit-mode.btn-danger').length == 0)
                    $('.gm-edit-mode').trigger('click');
                // now grab the content (use .html or .text) and store it where I can get it after the post.
                var t = $('<div>' + $('#mycanvas'').find('textarea').text() + '</div>').find('#gm-canvas');
                if (t.length == 0)
                    t = $('<div>' + $('#mycanvas'').find('textarea').text() + '</div>');
                $('#mycontent').val($('<div/>').text(t.html().trim()).html());

                // Get out of edit mode now (so the user does not see the source before the post)
                $('.gm-edit-mode').trigger('click');