davicotico / jQuery-Menu-Editor

Multilevel Menu Editor for Bootstrap 4.x (Html & Javascript code)
https://davidticona.com/demos/jQuery-Menu-Editor/
MIT License
191 stars 86 forks source link

full example php pdo insert or update ? #11

Closed Theolodewijk closed 4 years ago

Theolodewijk commented 5 years ago

Do you have full example php pdo insert or update ?

davicotico commented 5 years ago

Hi @Theolodewijk . I don't have, but basically the table schema is:

menu_id: int //primary key name: varchar(25) //the menu name content: text // <= THIS IS THE MENU, the json string

You can add more fields according to your needs.

webseitz commented 5 years ago

Hi @davicotico, I have written an AJAX-save function to save the whole menu in PHP/MySQL. What is the best way to call this function after every menu change?

davicotico commented 4 years ago

Hi @webseitz My apologies for the late response. The short answer is:

$('#btnSave').on('click', function () {
    var post = {
      "name": $('#txtName').val(), // the menu name
      "content": editor.getString(); // json output
    };
    $.post(/* your POST request */);
});