1

I would like to redirect to different pages based on list selection. I can get the button on click handle but how do i redirect to a page. Below is my code

 <div data-role="page" id="page1">
   <!-- Header --> 
   <div data-role="header"> 
<a href="#detailpage" data-rel="back" data-icon="arrow-l">back</a>
    <h1>List</h1>
    <a href="#" data-icon="arrow-r" data-iconpos="right" id="disnext">Next</a>      
   </div>  <!-- /Header -->
   <!-- Contents -->
   <div data-role="content">
    <ul data-role="listview" data-filter="true" id="list">
      <li data-name="val1">Value 1</li>
      <li data-name="val2">Value 2</li>
      <li data-name="val3">Value 3</li>
    </ul>
  </div>
 </div> <!-- /Contents -->
 </div>

 <!-- /Contents -->
 $("#disnext").click(function(e){

    alert("Button is clicked");
    // HERE I WANT TO REDIRECT TO DIFFERENT PAGE BASED ON LIST SELECTION


    return false;
    });

If user selects value 1 it should go to page 1, if user selects value 2 it should go to page 2 like that.

Thanks

User382
  • 864
  • 19
  • 42
  • Your answer is right here: http://stackoverflow.com/questions/503093/how-can-i-make-a-redirect-page-in-jquery-javascript – naspinski Mar 11 '13 at 20:13

2 Answers2

1

Something simple like this will work:

window.location.href = "http://somesite.com/" + $('#list').val();

similar question

Community
  • 1
  • 1
naspinski
  • 34,020
  • 36
  • 111
  • 167
0

Using the .index() property of the listview you can get the selected index.

$("#disnext").click(function(e){
    alert("Button is clicked");
    // HERE I WANT TO REDIRECT TO DIFFERENT PAGE BASED ON LIST SELECTION
    var selectedIndex = $("#list").index();

    //Logic here
    return false;
});
tymeJV
  • 103,943
  • 14
  • 161
  • 157