Reputation: 325
I have a problem to open with transitions jQuery Mobile.
I can not create a transition effect.
Here is my code...
<div id="main" data-role="content" data-theme="d">
<a href="#dialog" data-role="button" data-rel="dialog" data-transition="fade" data-inline="true">dialog</a>
<!-- ... -->
<div data-role="page" id="dialog"><!-- dialog-->
<div data-role="header" data-theme="e">
<h1>Foo</h1>
</div>
<div data-role="content" data-theme="e">
<p>Bar</p>
</div>
</div>
<!-- Footer -->
jQuery('#page').live('pageinit', function() {
$('.widget ul').attr('data-inset', 'true').attr('data-theme', 'd').attr('data-dividertheme', 'b').attr('data-role', 'listview');
$('.widget ul').listview();
});
jQuery('#page').live('changepage', function() {
$('#dialog', 'pop', true, true);
});
Thanks for your help.
Regards,
V.
Upvotes: 3
Views: 4427
Reputation: 76003
jQuery(document).delegate('#page', 'pageinit', function() {
$('.widget ul').attr('data-inset', 'true').attr('data-theme', 'd').attr('data-dividertheme', 'b').attr('data-role', 'listview').listview();
}).delegate('#page', 'changepage', function() {
$.mobile.changePage('#dialog', {
transition : 'pop',
role : 'dialog'//this means you don't have to declare `data-role="dialog"` on the page if you don't want to
});
});
Notice I chained the .listview()
function call and the second .delegate()
function call. I also changed out the .live()
for .delegate()
since as of jQuery 1.7, .live()
is depreciated. To navigate to a page you use $.mobile.changePage()
: http://jquerymobile.com/demos/1.1.0-rc.1/docs/api/methods.html
Upvotes: 1
Reputation: 5920
On the data-role="page" element, you need to add data-rel="dialog", instead of "id" to get the page to appear as a dialog.
See here: http://jquerymobile.com/test/docs/pages/page-dialogs.html
Upvotes: 6