Skip to content
This repository has been archived by the owner on Jan 20, 2019. It is now read-only.

Commit

Permalink
Added support for disabled state on initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippe Masset committed Jan 25, 2013
1 parent 0a9f98f commit 09240f9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
12 changes: 11 additions & 1 deletion examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@
</div>

<div class="select-container" style="left: 400px;">
<p>Disabled regular select (<a href="#" id="toggle-disabled">Toggle State</a>)</p>
<select disabled="disabled">
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
<option>Option 4</option>
</select>
</div>

<div class="select-container" style="left: 700px;">
<p>Select with optgroups</p>
<select>
<optgroup>
Expand All @@ -51,7 +61,7 @@
</select>
</div>

<div class="select-container" style="left: 700px;">
<div class="select-container" style="left: 1000px;">
<p>Select with optgroups and optgroup labels</p>
<select>
<optgroup label="Group 1">
Expand Down
7 changes: 7 additions & 0 deletions examples/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ $(document).bind("ready", function(){
.bind("change.simpleselect", function(){
console.log('change; new value='+ $(this).val());
});

$("#toggle-disabled").bind("click", function(e){
e.preventDefault();
var select = $(this).closest(".select-container").find("select");
if(select.prop("disabled")) select.simpleselect("enable");
else select.simpleselect("disable");
});
});
4 changes: 4 additions & 0 deletions jquery.simpleselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@
}
}
});
// disable the simpleselect if the select is disabled
if(simpleselectrefdata.ref.prop("disabled")){
simpleselectrefdata.disable();
}
// container for options
var simpleoptions = '<div class="options">';
// add options to the container
Expand Down
2 changes: 1 addition & 1 deletion jquery.simpleselect.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 09240f9

Please sign in to comment.