Skip to content

Commit

Permalink
consider disabled fieldset for disabled state
Browse files Browse the repository at this point in the history
  • Loading branch information
koenpunt committed Oct 21, 2016
1 parent 23a3ee6 commit d3f8133
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions coffee/chosen.jquery.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,16 @@ class Chosen extends AbstractChosen
@form_field_jq.show()

search_field_disabled: ->
@is_disabled = @form_field_jq[0].disabled
if(@is_disabled)
@is_disabled = @form_field.disabled || (=>
element = @form_field
disabled = false
while (element = element.parentElement) && element != element.ownerDocument
disabled = element.nodeName.toUpperCase() == 'FIELDSET' && element.disabled
break if disabled
disabled
)()

if @is_disabled
@container.addClass 'chosen-disabled'
@search_field[0].disabled = true
@selected_item.unbind "focus.chosen", @activate_action if !@is_multiple
Expand Down
12 changes: 10 additions & 2 deletions coffee/chosen.proto.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,16 @@ class @Chosen extends AbstractChosen
@form_field.show()

search_field_disabled: ->
@is_disabled = @form_field.disabled
if(@is_disabled)
@is_disabled = @form_field.disabled || (=>
element = @form_field
disabled = false
while (element = element.parentElement) && element != element.ownerDocument
disabled = element.nodeName.toUpperCase() == 'FIELDSET' && element.disabled
break if disabled
disabled
)()

if @is_disabled
@container.addClassName 'chosen-disabled'
@search_field.disabled = true
@selected_item.stopObserving "focus", @activate_action if !@is_multiple
Expand Down

0 comments on commit d3f8133

Please sign in to comment.