0

I have a standard Jquery mobile page to start, and I added some login elements (user pass). submit form calls itself, post, and if page sees a post it checks against mysql / hash etc, standard. It finds a match, sets session data, then sets header to account page, which loads fine.

The problem I am having though, is that events do not work until I reload the page. This is my first endeavor with logins and jquery mobile. Once I refresh everything is working as it should, but that is annoying. I have to be missing something simple here, any advice?

None of the a href="#etc" calls are recognized unless I reload the page.

I looked around at some of the questions but couldn't find an exact match. Sorry to bother. I appreciate being pointed in the right direction. I can post some specific code if it helps.

Thanks in advance.

Don Shappelle
  • 23
  • 1
  • 5
  • 1
    I haven't used jquery mobile.. but I think, posting snippet code of yours will help us analyze the problem ;). I'm sencha touch user, in my case, problem like this usually happens when the event failed to bind in a component such as a button for example.. – Yagi Dec 16 '12 at 03:56
  • that was a terrible attempt to add the code... basically I'm trying to click a button a href = #availability , i have a div id availability on account but it isn't recognized unless i refresh the page, despite displaying because the login was successful, without a refresh. – Don Shappelle Dec 16 '12 at 04:14
  • the page ids are not recognized, so the events do not go off when i do things like click the button. however, if i refresh the page, it all works. I need to remove the need for that page refresh somehow. Even when I log out, it loads the login page but with the jquery mobile script, and after logging in there, the events work. once it knows the elements exist it's all good, but it needs that one page reload to know. – Don Shappelle Dec 16 '12 at 04:21
  • It looks like the div is not ready yet when you click the button. Have you checked this out? It might help you http://stackoverflow.com/questions/9237659/jquery-mobile-user-login-best-practice – Yagi Dec 16 '12 at 04:29
  • Thanks. For now I implemented data-ajax="false" and will revisit it later since it is not terribly significant at the moment. I will let you know if your suggestion was effective, and prop you for it appropriately. – Don Shappelle Dec 17 '12 at 23:55
  • your answer is here; http://stackoverflow.com/questions/14379082/jquery-document-readyfunction-not-working – Spring Jan 18 '13 at 11:51

1 Answers1

0

Use this;

$(document).on('pageinit', '#secondpage', function() {
  console.log('test');
});

You can find details here in this answer;

JQuery $(document).ready(function () not working

Community
  • 1
  • 1
Spring
  • 11,333
  • 29
  • 116
  • 185