简体   繁体   English

jEditable-提交表格

[英]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? 我是Jeditable的新手,我想知道是否有一种方法可以生成和提交具有多个字段而不只是一个字段的自定义表单?

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". 给表单中的输入一个特定的类,将其称为“ my_form”。 Create a button that initializes the my_form class with JEditable by creating a function called makeEditable() . 通过创建一个名为makeEditable()的函数,创建一个使用JEditable初始化my_form类的按钮。 Also make the Save button have a class which we'll call save_button . 另外,使“保存”按钮具有一个称为“ 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(); 最后,您可以使用“ save_button”类的“提交”按钮发送所有修改的数据,这可以通过$('.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. 然后,您只需要更多的JQuery代码即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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