jQuery UI Slider多个事件触发器

时间:2010-12-14 00:17:46

标签: jquery-ui jquery

jQuery UI滑块允许在开始,滑动,更改,停止时触发事件(请参阅:http://jqueryui.com/demos/slider/#events

我需要在SLIDE期间在输入字段中显示值,并且需要在STOP时提交表单。但是,如果函数有两个偶数触发器,它似乎无法渲染滑块。

这是工作代码:

 <script>
 $(function() {
  $( "#slider-range" ).slider({
   range: true,
   min: 50,
   step: 10,
   max: 500,
   values: [ 75, 450 ],
   slide: function( event, ui ) {
    $( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] + " avg/night" );
    $( "#edit-nightlyavg-min" ).val( ui.values[ 0 ] );
    $( "#edit-nightlyavg-max" ).val( ui.values[ 1 ] );
   }
  });
  $( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
   " - $" + $( "#slider-range" ).slider( "values", 1 ) + " avg/night" );
  $( "#edit-nightlyavg-op" ).val( "between" );

 });
 </script>

这是非工作代码:

     <script>
 $(function() {
  $( "#slider-range" ).slider({
   range: true,
   min: 50,
   step: 10,
   max: 500,
   values: [ 75, 450 ],
   slide: function( event, ui ) {
    $( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] + " avg/night" );
    $( "#edit-nightlyavg-min" ).val( ui.values[ 0 ] );
    $( "#edit-nightlyavg-max" ).val( ui.values[ 1 ] );
   }
   stop: function( event, ui ) {
    $( "#views-exposed-form-location-directory-page-1" ).submit();
   }
  });
  $( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
   " - $" + $( "#slider-range" ).slider( "values", 1 ) + " avg/night" );
  $( "#edit-nightlyavg-op" ).val( "between" );

 });
 </script>

1 个答案:

答案 0 :(得分:1)

您在'幻灯片'功能后忘记了,