0

I am working with single page application, trying simple click event, its working with first screen but not working with second or third screen...

   $("#Signup").click(function() {
          alert("click success");
        $("#ButtonAction1").modal({
            show: true
     });

    });
Aryan
  • 133
  • 2
  • 9

4 Answers4

0

You must not use the same ID for different elements in the same page, use classes instead.

0

Make sure your DOM is already fully loaded.

$(function() { 
  $("#Signup").click(function() {
    alert("click success");
    $("#ButtonAction1").modal({
        show: true
    });
 });
});

If you add an element after the click event handler has been added, the element won't inherit it.

Zakk Diaz
  • 1,063
  • 10
  • 15
0

Try using the on instead of the click since it works with dynamic elements and delegates the events.

You can check out the difference between the methods here Difference between .on('click') vs .click()

 $("#Signup").on('click',function() {
        alert("click success");
        $("#ButtonAction1").modal({
            show: true
         });
    });
Community
  • 1
  • 1
Isabel Inc
  • 1,871
  • 2
  • 21
  • 28
0

It looks like you're buttons are dynamically loaded. You can use the following:

$('document').on('click', '#Signup', 
  function(){
    alert("click success");
    $("#ButtonAction1").modal({
      show: true
    });
  }
);

Source:

https://stackoverflow.com/a/16898442/6671505

$('#PARENT').on('click', '#DYNAMICALLY_ADDED_CHILD', function(){ CODE HERE });
Community
  • 1
  • 1
Davey
  • 2,355
  • 1
  • 17
  • 18