Forum: Ruby on Rails slider.js in ruby on rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jeff B. (Guest)
on 2006-03-14 04:02
(Received via mailing list)
Hello,
Is anyone using slider.js from script.aculo.us? I don't understand how
to integrate it into a form in rails. I want to do something like
adjust (slide) age from 16-100.
Thank You,
                     jeff
Roberto S. (Guest)
on 2006-03-14 04:23
(Received via mailing list)
I would approach this with a hidden field in your form and if you wana
have
it very easy, then use the helper from rails svn repository

http://dev.rubyonrails.org/browser/plugins/scripta...
Jeff B. (Guest)
on 2006-03-14 20:49
(Received via mailing list)
Wow, thanks for pointing me to that helper. I just can't seem to get
it to slide. Do I need a method in the controller to respond to the
movement?
Thank You,
                     jeff

Here is my rhtml:
  <%= slider_stylesheet %>
  <%= slider_field :mate, :generosity, :range => 1..10 %>

Here is the code it produces:
  <style>          div.slider {
            width: 150px;
            height: 5px;
            margin-top:5px;
            margin-bottom:5px;
            background: #ddd;
            position: relative;
          }
          div.slider div {
            position:absolute;
            width:8px;
            height:15px;
            margin-top:-5px;
            background: #999;
            border:1px outset white;
            cursor:move;
          }
</style>
  <input id="mate_generosity" name="mate[generosity]" type="hidden"
/><div class="slider"
id="mate_generosity_slider"><div></div></div><script
type="text/javascript">
//<![CDATA[
Element.cleanWhitespace('mate_generosity_slider');new
Control.Slider($('mate_generosity_slider').firstChild,'mate_generosity_slider',
{onChange:function(value){$('mate_generosity').value = value},
range:$R(1,10), slider_value:})
//]]>

</script>
This topic is locked and can not be replied to.