This is a migrated thread and some comments may be shown as answers.

[Solved] jquery double post

1 Answer 68 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sreyas
Top achievements
Rank 1
Sreyas asked on 25 May 2012, 09:50 AM
Dear Friends,

I am using a jquery to fill the checked combobox ID's into an array using the below code.
My Issue is,the POST method execute Twise.ie,the jquery will execute 2 times so the ID gets duplicated.
How to prevent jquery double post


$(document).ready(function () {

        //Select vendor Grid checkboxes state maintaining  
        $('#grvSelectVendor :checkbox').live('change', function (e) {
            if (this.name == 'selectedVendor') {
                var $check = $(this);
                //console.log($check);  
                if ($check.is(':checked')) {
                    //add id to selectedVendorID.  
                    selectedVendorID.push($check.val());
                   alert('hi'); //This will execute twise in a checkbox click
                }
                else {
                    //remove id from selectedJobIds.  
                    selectedVendorID = $.grep(selectedVendorID, function (item, index) {
                        return item != $check.val();
                    });
                }
            }
            
        });
    });


Please help me...


Regards
Sreyas MN

1 Answer, 1 is accepted

Sort by
0
Sreyas
Top achievements
Rank 1
answered on 04 Jun 2012, 11:54 AM
Hi,

For a solution,we can set

e.stopImmediatePropagation();



Sreyas MN
Tags
Grid
Asked by
Sreyas
Top achievements
Rank 1
Answers by
Sreyas
Top achievements
Rank 1
Share this question
or