Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

i've got an issue.

I'm a newbie in the world of jQuery Mobile, and with the ASP.Net MVC part I'm a little bit lost.

Here is my problem: In my mobile web site I want to change the navbar (that I use more like an appbar) buttons whereas I am on an Edit Page, or Home, etc....

So those pages (Edit, Show) are loaded in ajax, and on these pages I'm trying to fire an event like :

$(document).ready(function(){
   alert("Hello !");
});

But after some researchs, i found that in JQM with Ajax, events doesn't work that way, but more like this :

$(document).bind('pageinit', function(){
   alert("Hello !");
});

But this don't work for me (every page change the event is trigerred), maybe because in ASP.Net MVC Mobile we have only one data-role="page" and the rest of the content are loaded in ajax in the data-role="content", so I really don't know how I can fire an event when my "Ajax Loaded Kind of Page" is loaded ?

I had tried to live/bind on the listview of one of these pages but that does not work either :

$("[data-role='listview']").live('pageinit', function () {
    alert("hello");
});

To be more precise about what i'm trying to do : In ASP.Net MVC, my layout (who his common to all my pages) has a div with a data-role="page"attribute. This data-role is unique to my all app, and need to deal with it. But the fact is, when I load an other ASP.Net MVC Page in my code :

<div data-role="page" >
<div data-role="content"> Here my ASP.Net MVC Page</div>
</div>

I cannot use the $(document).bind('pagenit') because i don' load a page (data-role=page) but just a part of a data-role="content".

If you have any idea I will be glad to hear (more read) it, thanks in advance and sorry if my english is not really "understandable".

share|improve this question
What method are you using to load data into your content? – Gajotres Apr 16 at 11:15
It's my ASP.Net MVC Controller who returns me a View cshtml, this view is added via jquery mobile in my layout. <div data-role="content">@RenderBody()</div> – Romain Apr 16 at 11:57

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.