Reputation: 1370
How to use window.location method in jquery mobile. As am i developing an app using jquery mobile i need to change from one html page to other html page where i need to use window.location(). I know that to use
$.mobile.changePage( "page", { transition: "slide"} );
But here when using changePage() method getting problem with some js files. So, i thought of going to window.location() method.
As i am using the code is...
index.html
<section id="previewPage" data-role="page">
<div data-role="content" id="previewId" class="previewScreen">
<select name="select-choice-0" id="select-choice-1" data-native-menu="false">
<option value="email">Share via Email</option>
<option value="bbm" data-location='bbmIntegration.html'>Share via BBM</option>
<option value="sms">Share via SMS</option>
<option value="facebook">Share via Facebook</option>
<option value="twitter">Share via Twitter</option>
<option value="google">Share via Google</option>
</select>
</div>
</section>
sharingScreen.js
$('#select-choice-1').change(function() {
window.location = $(this).data('location');
//window.location = $('#select-choice-1').data('location')
});
When i click on Share via BBM , my html page needs to navigate to bbmIntegration.html page. But when i am running this in chrome browser when i click on Share via BBM it is displaying as "File /BBM/sample/www/undefined not found". can anyone please help me with this where i am doing the mistake...
Thanks in advance.........
Upvotes: 2
Views: 8064
Reputation: 28795
At the moment, your js is looking for a data attribute on the select
tag - it needs to be looking at the selected option
tag:
$('#select-choice-1').change(function() {
window.location = $(this).find('option:selected').data('location');
}
Upvotes: 2
Reputation: 5493
Try this:
$('#select-choice-1').change(function() {
window.location = $(this).find("option:selected").data('location');
});
Upvotes: 3