0

I am using jQuery mobile in my project and when I log on to system, then go to change password page, the change action is not firing (no action). But, when I refresh the page, it is firing. Briefly, the button on the page is not working when it is redirected from another page except itself. I have imported .css and .js files correctly in master page. (Generic Handler returns correct values and it is working)

head content:

<script type="text/javascript">
        $(document).ready(function () {
            $("#changePasswordBtn").click(function () {           
                $.ajax({
                    type: "POST",
                    url: "ChangePasswordHandler.ashx",
                    data: "oldPassword=" + $("#oldPassword").val() + "&newPassword=" + $("#newPassword").val() + "&reNewPassword=" + $("#reNewPassword").val(),
                    success: function (msg) {
                        if (msg == 0) $("#popupText").text("success");
                        else if (msg == 1) $("#popupText").text("wrong pass");
                        else if (msg == 2) $("#popupText").text("match error");
                        else if (msg == 3) $("#popupText").text("fill boxes");
                        else $("#popupText").text("error");                      
                    }
                });
            })
        });
    </script>

body content:

<input type="button" id="changePasswordBtn" value="Change Password" data-inline="true" />
Serge P
  • 1,173
  • 3
  • 25
  • 39
JoshuaJeanThree
  • 1,382
  • 2
  • 22
  • 41

2 Answers2

0

I have seen a similar problem in my project. Make sure that you are using different ids for buttons.

If the ids are same then the click event is not attached to the right button.

Anup
  • 627
  • 5
  • 19
0

I got a workaround for this issue by changing the way I load my pages. I put target="_self" into the href element so it don't load using the # system - this way the javascript loads with the initial page load while navigating from one page to a nother.

  • I will put the below link on my index.html page that will navigate to my signup.html page.

<a href="signup.html" target="_self" data-role="button" data-icon="arrow-r" data-iconpos="notext" data-theme="a" data-inline="true">Signup</a>

NOTE: You will lose the 'fancy' jQuery Mobile page transition feature

Lourens
  • 36
  • 1
  • 2