rails+select2+multiple

49 views
Skip to first unread message

Цибарт Сергей

unread,
Nov 16, 2016, 5:46:04 AM11/16/16
to select2
Good day! please help deal with the problem? have "form.js.coffee" file
...
searchUsersUrl = '/ users / select? limit = 7b
...
$ (UsersSelector, container) .select2
      minimumInputLength: 1
      width: 'resolve'
      multiple: true
      formatSearching: -> ( 'Search ...')
      formatInputTooShort: -> ( 'Enter a word to begin search')
      formatNoMatches: -> ( 'No results found')
      tags: true
      tokenSeparators: [ ",", ";"]
      createSearchChoice: (term, data) ->
        if mconf.Base.validateEmail (term)
          {Id: term, text: term}
      formatSelection: (object, container) ->
        text = if object.name?
          object.name
        else
          object.text
        mconf.Base.escapeHTML (text)
      ajax:
        url: searchUsersUrl
        dataType: "json"
multiple: true
        data: (term, page) ->
          q: term # search term
        results: (data, page) -> # parse the results into the format expected by Select2.
          results: data

    # This option will open the select2 field ready to search
    $ (UsersSelector) .select2 'open'

    # This option is optional. It was used just to improve the style of the page
    $ (UsersSelector) .select2 'focus'

    $ (UsersSelector) .on "change", =>
      @checkRequired ()

and "form.html.haml file"
...
= simple_form_for :invite, :url => send_invitation_bigbluebutton_room_path(room), :html => { :class => 'single-column'} do |f|
...
    .modal-body
      .invitation-header
        %span= t('.meeting_in')
        %span.meeting-url= join_webconf_url(room)
.....
      = f.input :users, :as => :string, :label => t('activerecord.attributes.invite.users')
....
Everything works except multiple choice multiple. Help 
Reply all
Reply to author
Forward
0 new messages