@@ -8,79 +8,82 @@ Note: These examples assume you have already included jQuery and this plugin.
8
8
9
9
### Simple usage
10
10
11
- ```
12
- <script type="text/javascript">
13
- $(function() {
14
- var options = [
15
- { text: 'one', value: 1 },
16
- { text: 'two', value: 2 }
17
- ];
18
-
19
- $('select').selectOptions(options);
20
- });
21
- </script>
22
-
23
-
24
- <select></select>
11
+ ``` javascript
12
+ $ (function () {
13
+ var options = [
14
+ { text: ' one' , value: 1 },
15
+ { text: ' two' , value: 2 }
16
+ ];
17
+
18
+ $ (' select' ).selectOptions (options);
19
+ });
25
20
```
26
21
27
22
### Preselected option
28
23
29
- ```
30
- <script type="text/javascript">
31
- $(function() {
32
- var options = [
33
- { text: 'one', value: 1 },
34
- { text: 'two', value: 2 }
35
- ];
36
-
37
- $('select').selectOptions(options, {selected: 2});
38
- });
39
- </script>
40
-
41
-
42
- <select></select>
24
+ ``` javascript
25
+ $ (function () {
26
+ var options = [
27
+ { text: ' one' , value: 1 },
28
+ { text: ' two' , value: 2 }
29
+ ];
30
+
31
+ $ (' select' ).selectOptions (options, { selected: 2 });
32
+ });
43
33
```
44
34
45
35
### Add a blank option
46
36
37
+ ``` javascript
38
+ $ (function () {
39
+ var options = [
40
+ { text: ' one' , value: 1 },
41
+ { text: ' two' , value: 2 }
42
+ ];
43
+
44
+ $ (' select' ).selectOptions (options, { includeBlank: ' choose something' });
45
+ });
47
46
```
48
- <script type="text/javascript">
49
- $(function() {
50
- var options = [
47
+
48
+ ### Optgroups
49
+
50
+ ``` javascript
51
+ $ (function () {
52
+ var options = {
53
+ " Group 1" : [
51
54
{ text: ' one' , value: 1 },
52
- { text: 'two', value: 2 }
53
- ];
55
+ { text: ' two' , value: 2 }
56
+ ],
57
+ " Group 2" : [
58
+ { text: ' three' , value: 3 },
59
+ { text: ' four' , value: 4 }
60
+ ]
61
+ };
54
62
55
- $('select').selectOptions(options, {includeBlank: 'choose something'});
56
- });
57
- </script>
58
-
59
-
60
- <select></select>
63
+ $ (' select' ).selectOptions (options);
64
+ });
61
65
```
62
66
67
+ ### Putting it all together
63
68
64
- ### Optgroups
65
-
66
- ```
67
- <script type="text/javascript">
68
- $(function() {
69
- var options = {
70
- "Group 1": [
71
- { text: 'one', value: 1 },
72
- { text: 'two', value: 2}
73
- ],
74
- "Group 2": [
75
- { text: 'three', value: 3 },
76
- { text: 'four', value: 4 }
77
- ]
78
- };
79
-
80
- $('select').selectOptions(options);
81
- });
82
- </script>
83
-
84
-
85
- <select></select>
69
+ ``` javascript
70
+ $ (function () {
71
+ var options = {
72
+ " Group 1" : [
73
+ { text: ' one' , value: 1 },
74
+ { text: ' two' , value: 2 }
75
+ ],
76
+ " Group 2" : [
77
+ { text: ' three' , value: 3 },
78
+ { text: ' four' , value: 4 }
79
+ ]
80
+ };
81
+
82
+ $ (' select' ).selectOptions (options, { includeBlank: ' choose something' , selected: 3 });
83
+ });
86
84
```
85
+
86
+ ## Contributing
87
+ I've chosen to write this plugin in Coffeescript and compile it for easy use. If you wish to contribute, please edit the Coffeescript file and compile it into JS before committing.
88
+
89
+ For directions on how to use Coffeescript, please reference http://coffeescript.org
0 commit comments