How to wrap every select of date_select with a div in Rails?

后端 未结 5 1913
抹茶落季
抹茶落季 2020-12-19 01:08

I\'m using Ruby on Rails 3 to create a form for the user, where he can save his birthdate. All the actions around the controller and model work just fine. But I\'m having tr

5条回答
  •  情书的邮戳
    2020-12-19 01:37

    Method 1 (Difficult)

    Override the date_select code to handle this special instance for you: https://github.com/rails/rails/blob/master/actionview/lib/action_view/helpers/date_helper.rb#L283

    Method 2 (Easy)

    Use jQuery:

    // Find all select boxes that have an ID attribute containing "birthday"
    // and wrap a div tag around them with a certain class
    $('select[id*="birthday"]').wrapAll('
    ');

提交回复
热议问题