Change event not fired on slider

Change event not fired on slider

Hi,
I'm new to jQueryMobile framework, while I was running some tests to better understand all the framework I've step into this piece of code (that I have written), that doesn't work and I can't understand why...
basically there are 2 pages, in each page there is a form with a slider that should react to the "change" event writing its value to a textbox. This works in the first page, but not in the second page although the code is the same...

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Page Title</title>
  5. <meta name="viewport" content="width=800, initial-scale=1">
  6. <link rel="stylesheet" href="jquery.mobile-1.4.0/jquery.mobile-1.4.0.min.css" />
  7. <script src="jquery-2.1.0/jquery-2.1.0.min.js"></script>
  8. <script src="jquery.mobile-1.4.0/jquery.mobile-1.4.0.min.js"></script>
  9. <script>
  10. $(document).ready(function() {
  11. $("#slider-1").change(function() { 
  12. var sliderValue = $(this).val();
  13. $("#text-1").val(sliderValue);
  14. });
  15. $("#slider-2").change(function() { 
  16. var sliderValue = $(this).val();
  17. $("#text-2").val(sliderValue);
  18. });
  19. });
  20. </script>
  21. </head>
  22. <body>

  23. <!-- /page1 -->
  24. <div data-role="page" id="page_1">
  25. <!-- /header -->
  26. <div data-role="header">
  27. <h1>Page 1</h1>
  28. </div>

  29. <!-- /content -->
  30. <div role="main" class="ui-content">
  31. <form id="form-1">
  32.    <label for="slider-2">Slider-1:</label>
  33.    <input type="range" name="slider-1" id="slider-1" data-highlight="true" min="0" max="100" value="50">
  34. <label for="text-1">Slider-1 value:</label>
  35. <input type="text" name="text-1" id="text-1" value="50">
  36. </form>
  37. <a href="#page_2" class="ui-btn">Page 2</a>
  38. </div>
  39. </div>

  40. <!-- /page2 -->
  41. <div data-role="page" id="page_2">

  42. <!-- /header -->
  43. <div data-role="header">
  44. <h1>Page 2</h1>
  45. </div>

  46. <!-- /content -->
  47. <div role="main" class="ui-content">
  48. <form id="form-2">
  49.    <label for="slider-2">Slider-2:</label>
  50.    <input type="range" name="slider-2" id="slider-2" data-highlight="true" min="0" max="100" value="50">
  51. <label for="text-2">Slider-2 value:</label>
  52. <input type="text" name="text-2" id="text-2" value="50">
  53. </form>
  54. <a href="#page_1" class="ui-btn">Page 1</a>
  55. </div>
  56. </div>
  57. </body>
  58. </html>

I can't understand why in the first page the change event is fired and not in the second page...

Samuele.