4

I am using Charisma Admin Panel.
In that, jQuery datatable is used.

In my table, a row contains the following:

column1 = integer
column2 = text
column3 = 2 buttons (view and delete)

The View button is responsible to fetch some data from server and show that data in modal popup.

I am able to view that popup only if I am on the first page. For other pages, when I click on view button, required data is fetched from server (able to see it in firebug), but it is not showing that modal popup again.

I think it is because of live fields.
Any help please.

click event is used as follows:

$('.btn-setting').click(function(e){ 
e.preventDefault();
$('#myModal').modal('show'); 
});
Muhammad Usman
  • 12,439
  • 6
  • 36
  • 59
Pranav
  • 2,054
  • 4
  • 27
  • 34
  • not sure if that's the cause, but if the event does not trigger after a partial refresh, maybe it's because the click event is assigned using `click` or `live` or `on` function, and after refreshing that button it's not assigned again. – Naryl Dec 31 '12 at 10:24
  • click event is used as - `$('.btn-setting').click(function(e){ e.preventDefault(); $('#myModal').modal('show'); });` but did not understand that "partial refresh" term, sorry but I am new to this. – Pranav Dec 31 '12 at 10:33
  • what I mean is: if the button is rewritten after you change the page (for example with a .html() function) you need to apply again the click event. – Naryl Dec 31 '12 at 10:39

1 Answers1

3

try doing with 'on':

$('.btn-setting').on('click', function(e){ 
    e.preventDefault();
    $('#myModal').modal('show'); 
});

OR

$(document).on('click', '.btn-setting', function(e){
  e.preventDefault();
  $('#myModal').modal('show'); 
});
Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162
  • Thanks a lot, your second answer worked :) thanx. can you please tell me the difference between what i have used and this one ? It worked. – Pranav Dec 31 '12 at 11:18
  • the code in answer works for content added dynamically on the page, so when content of your page is generated dynamically the code works as needed, check jquery .on method for more details – Sudhir Bastakoti Dec 31 '12 at 11:37