jquery mobile link from listview does not reload the page












1














I have been learning a lot about jquery mobile and the mechanics on how it handles events and page reloads. I am having an issue where some click events are not firing more than once but it depends on how I approach the page.



One of those ways is when I have a link in a listview widget as apposed to a link by itself. I have noticed that when I click on a link from a listview then it does not reload the new page but instead just reloads the content. Therefore the click event is only triggered once since it is not reloaded.



<div class="container tickets">
<ul data-role="listview" data-filter="true">
<li><a href="/link1/index.php" data-ajax="false">Link1</a></li>
<li><a href="/link2/index.php" data-ajax="false">Link2</a></li>
<? } ?>
</ul>
</div>


If I have just a hard link like



<a href="/link1/index.php">Link1</a>


Then it will reload the page and the click event will fire every time.



My question is it better to leave data-ajax="false" off the link in the listview to allow a smoother transition or is there any issue with just causing a page reload every time. And if I do decide to leave data-ajax="false" out of the picture how can I get the click event to fire every time?



From what I understand using pagebeforeshow for my event trigger should allow for my click event to fire every time even with the smooth transition, but it is not. Am I missing something here?



$(document).on('pagebeforeshow', function() {
$(document).on('click', '.change_status', function() {
// do stuff
})
})









share|improve this question
























  • a detailed explanation of the single-page model: peachpit.com/articles/article.aspx?p=1858265&seqNum=2
    – deblocker
    Nov 23 at 8:42


















1














I have been learning a lot about jquery mobile and the mechanics on how it handles events and page reloads. I am having an issue where some click events are not firing more than once but it depends on how I approach the page.



One of those ways is when I have a link in a listview widget as apposed to a link by itself. I have noticed that when I click on a link from a listview then it does not reload the new page but instead just reloads the content. Therefore the click event is only triggered once since it is not reloaded.



<div class="container tickets">
<ul data-role="listview" data-filter="true">
<li><a href="/link1/index.php" data-ajax="false">Link1</a></li>
<li><a href="/link2/index.php" data-ajax="false">Link2</a></li>
<? } ?>
</ul>
</div>


If I have just a hard link like



<a href="/link1/index.php">Link1</a>


Then it will reload the page and the click event will fire every time.



My question is it better to leave data-ajax="false" off the link in the listview to allow a smoother transition or is there any issue with just causing a page reload every time. And if I do decide to leave data-ajax="false" out of the picture how can I get the click event to fire every time?



From what I understand using pagebeforeshow for my event trigger should allow for my click event to fire every time even with the smooth transition, but it is not. Am I missing something here?



$(document).on('pagebeforeshow', function() {
$(document).on('click', '.change_status', function() {
// do stuff
})
})









share|improve this question
























  • a detailed explanation of the single-page model: peachpit.com/articles/article.aspx?p=1858265&seqNum=2
    – deblocker
    Nov 23 at 8:42
















1












1








1







I have been learning a lot about jquery mobile and the mechanics on how it handles events and page reloads. I am having an issue where some click events are not firing more than once but it depends on how I approach the page.



One of those ways is when I have a link in a listview widget as apposed to a link by itself. I have noticed that when I click on a link from a listview then it does not reload the new page but instead just reloads the content. Therefore the click event is only triggered once since it is not reloaded.



<div class="container tickets">
<ul data-role="listview" data-filter="true">
<li><a href="/link1/index.php" data-ajax="false">Link1</a></li>
<li><a href="/link2/index.php" data-ajax="false">Link2</a></li>
<? } ?>
</ul>
</div>


If I have just a hard link like



<a href="/link1/index.php">Link1</a>


Then it will reload the page and the click event will fire every time.



My question is it better to leave data-ajax="false" off the link in the listview to allow a smoother transition or is there any issue with just causing a page reload every time. And if I do decide to leave data-ajax="false" out of the picture how can I get the click event to fire every time?



From what I understand using pagebeforeshow for my event trigger should allow for my click event to fire every time even with the smooth transition, but it is not. Am I missing something here?



$(document).on('pagebeforeshow', function() {
$(document).on('click', '.change_status', function() {
// do stuff
})
})









share|improve this question















I have been learning a lot about jquery mobile and the mechanics on how it handles events and page reloads. I am having an issue where some click events are not firing more than once but it depends on how I approach the page.



One of those ways is when I have a link in a listview widget as apposed to a link by itself. I have noticed that when I click on a link from a listview then it does not reload the new page but instead just reloads the content. Therefore the click event is only triggered once since it is not reloaded.



<div class="container tickets">
<ul data-role="listview" data-filter="true">
<li><a href="/link1/index.php" data-ajax="false">Link1</a></li>
<li><a href="/link2/index.php" data-ajax="false">Link2</a></li>
<? } ?>
</ul>
</div>


If I have just a hard link like



<a href="/link1/index.php">Link1</a>


Then it will reload the page and the click event will fire every time.



My question is it better to leave data-ajax="false" off the link in the listview to allow a smoother transition or is there any issue with just causing a page reload every time. And if I do decide to leave data-ajax="false" out of the picture how can I get the click event to fire every time?



From what I understand using pagebeforeshow for my event trigger should allow for my click event to fire every time even with the smooth transition, but it is not. Am I missing something here?



$(document).on('pagebeforeshow', function() {
$(document).on('click', '.change_status', function() {
// do stuff
})
})






jquery jquery-mobile






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 at 21:45

























asked Nov 20 at 21:31









Cesar Bielich

2,12142350




2,12142350












  • a detailed explanation of the single-page model: peachpit.com/articles/article.aspx?p=1858265&seqNum=2
    – deblocker
    Nov 23 at 8:42




















  • a detailed explanation of the single-page model: peachpit.com/articles/article.aspx?p=1858265&seqNum=2
    – deblocker
    Nov 23 at 8:42


















a detailed explanation of the single-page model: peachpit.com/articles/article.aspx?p=1858265&seqNum=2
– deblocker
Nov 23 at 8:42






a detailed explanation of the single-page model: peachpit.com/articles/article.aspx?p=1858265&seqNum=2
– deblocker
Nov 23 at 8:42



















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53401875%2fjquery-mobile-link-from-listview-does-not-reload-the-page%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53401875%2fjquery-mobile-link-from-listview-does-not-reload-the-page%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

Refactoring coordinates for Minecraft Pi buildings written in Python