Jquery remove old functions and on click handlers -
i have page button on loads modal.
in modal display data.
this data can example consist of 5 entries of table when entry gets removed, data refreshed. same thing when entry added.
now when close modal clicking outside of , reopen it. functions attached first modal still there , firing. if add entry. ajax , scripts fired/called twice.
code :
$(document).on('click','.remove_team',function(){ var tournament_id = $(this).data('tourn'); $.ajax({ url :'./organisations/waiting_list/team_assignement.php', type :'post', data : { action : 'remove_team', team_id : $(this).data('team'), tourn : $(this).data('tourn') }, success : function(){ loadparticipantlist(tournament_id); } }) }) function loadparticipantlist(tournament){ $.ajax({ url :'./organisations/waiting_list/team_assignement.php', type :'post', data : { action :'fetch_team_participants', tournament : tournament },success : function(res){ res = jquery.parsejson(res); $("#counter_"+tournament).html(res.count); $("#div_"+tournament).html(res.teams); } }) }
what correct way remove click handler , directly add again ajax fires?
Comments
Post a Comment