givanz / VvvebJs

Drag and drop page builder library written in vanilla javascript without dependencies or build tools.
https://www.vvveb.com/vvvebjs/editor.html
Apache License 2.0
7.3k stars 1.66k forks source link

Question regarding a missing name field on New page Modal? #182

Open shabeebrizvi opened 4 years ago

shabeebrizvi commented 4 years ago

@givanz this is awesome... Good job! I had few hick-ups running this as is but after investing few hours was able to get the code working Save and New Page functionality works now.... but I got few questions regarding newPage which I don't understand? See my comments in the code especially about data.name as there is no such field in the modal window. Or is it something that i am missing????

builder.js line 1616
`newPage : function () {

    var newPageModal = $('#new-page-modal');

    newPageModal.modal("show").find("form").off("submit").submit(function( e ) {

        var data = {};
        $.each($(this).serializeArray(), function() {
            data[this.name] = this.value;
        });         

        // where is this name initialized??
        Vvveb.FileManager.addPage(name, data);
        e.preventDefault();

        var url = "save.php";

        return Vvveb.Builder.saveAjax(url, data.startTemplateUrl, function (data) {

                                     // There is no input field called name in the modal widow so data.name is empty
                Vvveb.FileManager.loadPage(data.name);
                Vvveb.FileManager.scrollBottom();
                newPageModal.modal("hide");
        });
    });

}`
assadnazar commented 3 years ago

https://github.com/givanz/VvvebJs/blob/34fbb54681db07ddd728b61c282e80f3407dd9c3/editor.html#L1314