Reputation: 3128
I have this working fine when loading the page normally (visiting the page via the addressbar):
$(function () {
$("#verify").click(function (event) {
event.preventDefault();
// ...
But if I navigate to the page (that contains the button: id="verify") via pjax calls (https://github.com/defunkt/jquery-pjax), the JS code doesn't see the button.
It works if I hit refresh.
How can I overcome this problem?
Upvotes: 0
Views: 89
Reputation: 388396
It is because when you use pjax, you are dealing with dynamically created elements, in such cases you need to use event delegation
Try
$(function () {
$(document).on('click', "#verify", function (event) {
event.preventDefault();
Upvotes: 1