Skip to content

Commit

Permalink
Fixed width calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
McFizh committed Mar 24, 2016
1 parent 713fa80 commit 46a493c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 25 deletions.
55 changes: 35 additions & 20 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</head>
<body>

This is just a basic select with static data.<br/>
<select id="select1">
<option value="-1">option a</option>
<option value="1">option b</option>
Expand All @@ -20,33 +21,45 @@

<br/><br/>

<div style="width: 400px; border: 1px dashed black">
<select id="select2" style="width: 100%;">
<option value="-1">option a</option>
<option value="1">option b</option>
<option value="2" selected>option c</option>
<option value="3">option d</option>
<option value="4">option e</option>
<option value="5">option f</option>
<option value="6">option g</option>
<option value="7">option h</option>
</select>
</div>
This div is displayed after select component is created. This causes problems with jQuery outerWidth.<br/>
<br/>
<div id="havoc" style="width: 800px; border: 1px dashed black; display: none; padding: 5px;">

This select doesn't have search<br/>
<div style="width: 80%; display: inline-block;">
<select id="select2" style="width: 100%;">
<option value="-1">option a</option>
<option value="1">option b</option>
<option value="2" selected>option c</option>
<option value="3">option d</option>
<option value="4">option e</option>
<option value="5">option f</option>
<option value="6">option g</option>
<option value="7">option h</option>
</select>
</div>

<br/><br/>
<br/><br/>
Data is loaded from file.json .. component doesn't respect '---' selection.<br/>
<div style="width: 80%; display: inline-block;">
<select id="select3">
<option value="-1">---</option>
</select>
</div>

<select id="select3">
<option value="-1">---</option>
</select>
</div>

<select id="select4">
<option value="-1">---</option>
<br/>
Data is loaded from file.json .. component respects selection.<br/>
<select id="select5" style="width: 340px;">
<option value="1">abc</option>
</select>

<br/><br/>

<select id="select5">
<option value="1">abc</option>
Note: This select is supposed to fail:<br/>
<select id="select4">
<option value="-1">---</option>
</select>

<script>
Expand Down Expand Up @@ -81,6 +94,8 @@
console.log($(this).val());
});

$("#havoc").show()

</script>
</body>
</html>
4 changes: 2 additions & 2 deletions dist/js/tinyselect.min.js

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

4 changes: 2 additions & 2 deletions js/tinyselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Licensed under MIT license.
*
* @version 1.0.3
* @version 1.0.4
* @author Pekka Harjamäki
*/
;(function($) {
Expand Down Expand Up @@ -53,7 +53,7 @@
// Create container for select, search and options
this.state.container = $("<div></div>").
addClass("tinyselect").
css({ width: $el.outerWidth() });
css({ width: $el.css("width") });

// Create the select element
this.state.selectBox = $("<div></div>").
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tinyselect",
"description": "jQuery plugin to create custom select element. Supports ajax loading and filtering.",
"version": "1.0.3",
"version": "1.0.4",
"author": "Pekka Harjamäki <[email protected]>",
"homepage": "http://mcfizh.github.io/tinySelect/",
"license": "MIT",
Expand Down

0 comments on commit 46a493c

Please sign in to comment.