Reputation: 2153
I have a jqgrid component inside my page and the rows of the grid are create with values and actions, for example:
colum: name adresss job edit
row 1: jorge my adress architect [value]
I populate the grid with several rows from a database and aech row have a value in column edit to the personal page for editing actions.
this value have this structure:
<div><span class="edit" idperson="' + items[i].id + '">Edit</span></div>
in the same script I put this:
$('.edit').live('click', this.clickedit);
and the function is:
clickedit: function(){
$.ajax('person/personedit.htm', {
cache: false,
type : 'POST',
data : { idperson: $(this).attr('idperson')},
success : function(response){
//some actions.....
}
});
},
in my java code I have a spring controller that recieve this call from jquery and do something.
The first time I clic the Edit action in a row all is OK, but after a while working with the application I see that a single edit action is called several times so the clickedit function execute 2, or 3 or 4 times and my java code are hit the same numbers of times.
any idea about this issue???
UPDATE:
I start to using onCellSelect now. But I have a problem. In a single cell I can put 3 differents action in this way:
var actions = 'editedOK ? '<div><span class="edit1" idperson="' + items[i].id + '" >EDITOK1 </span><span class="edit2" idperson="' + items[i].id + '">EDITOK2</span></div>' : '<div><span class="editnook1" idperson="' + items[i].id + '">EDITNOOK1</span></div>';
if actions = true I see in the same cell "EDITOK1 EDITOK2" and if actions = false I see in this cell "EDITNOOK1"
everyone of this actions have associates functions with differents behaviour when I clic in it.
If I use onCellSelect it´s possible to determinate when I hit EDITOK1, when I hit EDITOK2 and when I hit EDITNOOK1. More important is to determinate between EDITOK1 and EDITOK2.
Upvotes: 0
Views: 675
Reputation: 221997
I suppose that you calls $('.edit').live('click', this.clickedit);
multiple times. It's the reason why this.clickedit
handler will be called more as one time.
I recommend you don't use any explicit binding of this.clickedit
callback. Instead of that you can use beforeSelectRow
or onCellSelect
. See the answer and this one for the corresponding code examples.
Upvotes: 1