ruby-on-railsrubybest-in-placeedit-in-placebootstrap-slider

Bootstrap data slider in place editing and safe to database


I am trying to set up a table in an index view of my "relations" controller including an editable dataslider which directly safes the "preference" value to my db. Is it possible to combine bootstrap dataslider with "best_in_place" or form method or is that nonsense? (I am newbie on ruby on rails) Does anybody have any suggestions ? Thanks for your help!

the current relations index view

I am using "bootstrap slider rails"


Solution

  • Doing what you want through forms may be a little challenging - you'll have to nest each one in a form, ensure that submitting the form doesn't reload the page, etc.

    The easiest thing to do might be to pass an onChange function to your data slider that posts the data to the backend. Something along the lines of this (I don't know the data-slider component so I'm sort of guessing as to syntax):

    html:
    <input id="slider" />
    js:
    $("#slider").slider().change(function(data) {
      $.post({ url: "my/url",
               success: function(response) { ... },
               ...
      });
    });