kenxran / jquery-datatables-editable

Automatically exported from code.google.com/p/jquery-datatables-editable
0 stars 0 forks source link

Adding form freeze when validate plugin is not included #34

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

I'm trying to use your script to add a record into a mysql base.

With the last version (1.2.8.) it's impossible to validate the form (Ok and 
cancel buton don't make any action)(the dialog box is still visible).

With an older version of the script, I can validate the form, but the optional 
Add page (sAddURL) is not use. The page (no XHR transaction).
The page is reloaded (like a $_SERVER['PHP_SELF'] )with this url
mypage.php?input1=value1&input2=value2

I don't have any problem with update fonction.

<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
    $('#table_edit').dataTable({
            "sPaginationType": "full_numbers",
            "bJQueryUI": true,
            "aaSorting": [ [0,'asc'], [1,'asc'] ],
            "oLanguage": {"sUrl": "javascript/datetable_langFR.txt" }           
        }); 
    $('#table_edit').dataTable().makeEditable({
                            sUpdateURL: "script/updatedata.php",
                            sAddURL: "script/adddata.php",
                            });     
});
</script>   

 <form id="formAddNewRow" action="" title="Add">
        <label for="input1">ID</label><br />
    <input type="text" name="input1" id="input1" class="required" rel="0" />
        <br />
        <label for="input2">Text </label><br />
    <input type="text" name="input2" id="input2" rel="1" />
        <br />
</form>     

Original issue reported on code.google.com by babali33...@gmail.com on 15 Jun 2011 at 7:31

GoogleCodeExporter commented 9 years ago
Is there any error in JS cosole?
Validation works fine in 
http://jquery-datatables-editable.googlecode.com/svn/trunk/addingrecords.html 
here is used 1.2.8. version. I have checked it in the FF, Chrome and IE.

Is it possible that you have some other script that override submit function 
and sent request to the mypage.php?

Original comment by joc...@gmail.com on 15 Jun 2011 at 11:54

GoogleCodeExporter commented 9 years ago
you need to make sure you include jquery.validate.js in your page's header, and 
you need to have a function like this:

$("#formAddNewRow").validate({
        rules: {
            input1: "required",
            input2: "required",
        },
        onkeyup: false,
        onclick: false,
        messages: { },
        invalidHandler: function(e, validator) {
            var errors = validator.numberOfInvalids();
            if (errors) {
                var message = errors == 1
                    ? 'You missed 1 field. It has been highlighted below'
                    : 'You missed ' + errors + ' fields.  They have been highlighted below';
                $("div.error span").html(message);
                $("div.error").show();
            } else {
                $("div.error").hide();
            }
        }   
});

Original comment by dmol...@gmail.com on 16 Jun 2011 at 12:09

GoogleCodeExporter commented 9 years ago

Original comment by joc...@gmail.com on 15 Sep 2011 at 10:21