I’m using jQuery Mobile and trying to figure out how to change a page correctly using a select drop-down and some jQuery. The problem I’m having is the page loads with the content, but if I keep switching the selected value, the page loads multiple times. I’m assuming it’s because the page contents from the last selection still exist in the DOM? Here’s what I have so far:
jQuery:
$(document).ready(function() {
$("select[name=ProjectID]").change(function() {
var projectID = $(this).val();
window.location.hash = "/tasks.cfm?pid=" + projectID;
});
});
HTML:
<select name="ProjectID">
<option value="1">Project 1</option>
<option value="2">Project 2</option>
</select>
Tried using $.mobile.changePage(), but saw the same result. Any way to get around this?
I would go about it like this:
JS
HTML