Sha256: f23be3a5a831722fedbc19cc4518cd712bfec8b24e73f3cea8752a816f78c535

Contents?: true

Size: 747 Bytes

Versions: 16

Compression:

Stored size: 747 Bytes

Contents

#
# Converts a select list into a bootstrap button-group with radio button behaviour
#
(($) ->
  $.widget 'ransack.button_group_select',
    options: {}

    _create: ->
      el = @element
      val = el.val()
      el.hide()

      html = '<div class="btn-group btn-group-select" data-toggle="buttons-radio">'
      el.find('option').each (i, o) ->
        html += "<button class=\"btn#{if o.value == val then ' active' else ''}\" type=\"button\" value=\"#{o.value}\">#{o.text}</button>"

      # Insert HTML after hidden select
      el.after html

      # Update select val when button is clicked
      btn_group = el.next()
      btn_group.on 'click', 'button.btn', (e) =>
        @element.val $(e.currentTarget).val()
        true

) jQuery

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
ransack_ui-2.0.1 app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee
ransack_ui-2.0.0 app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee
fat_free_crm-0.19.0 vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee
ransack_ui-1.4.0 app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee
ransack_ui-1.3.4 app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee
ransack_ui-1.3.3 app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee
ransack_ui-1.3.2 app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee
ransack_ui-1.3.1 app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee
ransack_ui-1.3.0 app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee
ransack_ui-1.2.2 app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee
ransack_ui-1.2.1 app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee
ransack_ui-1.2.0 app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee
ransack_ui-1.1.0 app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee
ransack_ui-1.0.2 app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee
ransack_ui-1.0.1 app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee
ransack_ui-1.0.0 app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee