简体   繁体   中英

jEditable - Submit a Form

I'm pretty new to Jeditable and I was wondering if there is a way to generate and submit a custom form with multiple fields instead of just one field?

I've taken a look at this tutorial for some hints and I've made a bit of progress. I'm not sure if I'm on the right track though.

Here's one idea where you can save whatever has been edited in the form. Give the inputs in the form a certain class, call it "my_form". Create a button that initializes the my_form class with JEditable by creating a function called makeEditable() . Also make the Save button have a class which we'll call save_button .

$(function(){
    function makeEditable() {
        $(".my_form").editable('MyPhpPage.php', {
             // YOUR CUSTOMIZATION
             submit : '<button class="save_button">Save</button>',
        });

     makeEditable();
    });

You can finally send all the modified data with with a "Submit" button of class "save_button", and that's accomplished with $('.my_form').find('.save_button').click(); .

This may be not robust enough for your form as you might want to create constraints such as require all of them to be non-empty. You then just need a bit more JQuery code to do so.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM