Rails check_box_tag how to pass value when checked ajaxily

后端 未结 4 1827
死守一世寂寞
死守一世寂寞 2021-01-01 03:58

On my index page for my Task model, I want to show a checkbox for every row that corresponds to the boolean field \"complete\" in my Task database table.

Currently m

4条回答
  •  灰色年华
    2021-01-01 04:39

    As of Rails 4, you should be able to ditch all the JS from the original answer. The code in your question should just work due to jQuery UJS magic.

    It turns out that adding remote: true to an input causes jquery-ujs to make it ajax-y in all the nice ways. Thoughtbot's "A Tour of Rails jQuery UJS" briefly touches this (and many other good things available); the "Unobtrusive scripting support for jQuery" page in the jQuery UJS wiki does a thorough job on this as well.

提交回复
热议问题