bernat / best_in_place

A RESTful unobtrusive jQuery Inplace-Editor and a helper as a Rails Gem
http://blog.bernatfarrero.com/in-place-editing-with-javascript-jquery-and-rails-3/
1.2k stars 571 forks source link

Issues with Select2 for Rails #510

Open kotowick opened 8 years ago

kotowick commented 8 years ago

Trying to integrate best in place with Select2 (https://github.com/argerim/select2-rails). Anyone accomplish this?

Need it to work with select2 multi-select too..

zamakkat commented 8 years ago

Hey there I had the same issue. After quite some time trying to get it to work, here is what I did:

= best_in_place @profile, :skill_list, 
    class: 'js-skill-list', inner_class: 'js-skills-input', 
    data: { tags: skills_collection },
    ok_button: 'Save', cancel_button: 'Cancel'
$('.best_in_place').on 'best_in_place:activate', ->
    $('input.js-skills-input').select2
        tags: $('.js-skill-list').data('tags')

That's it. Now when the best_in_place field gets activated, the Select2 will get initiated with whatever options you pass to it. When you click OK / Save, the input gets submitted like a normal text field (Do note the monkey patch though).

fabrouy commented 7 years ago

https://gist.github.com/argent-smith/3835854