1

I'm creating a table, after that I convert table to jQuery dataTable, for this I'm using dataTable.responsive and an option to display information in a modal, problem here is that my function button is only displayed on the modal, so my question is what can I do to access to that button, I'm trying doing this but do not work.

$('#TableBody').on('click', '.glyphicon-edit', function () {
    alert("Click!");
});

This do not work too:

//example is my table id
$('#example').on('click', '.glyphicon-edit', function () {
    alert("Click!");
});

Here is my full code to see my problem properly.

3
  • 1
    And if you do $(document).on('click', '.glyphicon-edit'... does that work Commented Oct 25, 2016 at 19:54
  • @adeneo Yes! that work, but what if I have more than one input with .glyphicon-edit? Should I use a personalized class or id? Commented Oct 25, 2016 at 19:57
  • 1
    You should use the closest non-dynamic parent element. Meaning, you should use the closest parent that isn't replaced by the dataTables plugin Commented Oct 25, 2016 at 19:58

1 Answer 1

1

If you're using Bootstrap styling, use the code below. This will narrow your selector to the element in the modal opened by jQuery DataTables.

$(document).on('click', '.dtr-bs-modal .glyphicon-edit', function(){
   // ... skipped ...
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.