Skip to content

Commit 521edff

Browse files
committed
changes to readme
1 parent 901fcbe commit 521edff

File tree

1 file changed

+64
-61
lines changed

1 file changed

+64
-61
lines changed

readme.md

Lines changed: 64 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -8,79 +8,82 @@ Note: These examples assume you have already included jQuery and this plugin.
88

99
### Simple usage
1010

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+
});
2520
```
2621

2722
### Preselected option
2823

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+
});
4333
```
4434

4535
### Add a blank option
4636

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+
});
4746
```
48-
<script type="text/javascript">
49-
$(function() {
50-
var options = [
47+
48+
### Optgroups
49+
50+
```javascript
51+
$(function() {
52+
var options = {
53+
"Group 1": [
5154
{ 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+
};
5462

55-
$('select').selectOptions(options, {includeBlank: 'choose something'});
56-
});
57-
</script>
58-
59-
60-
<select></select>
63+
$('select').selectOptions(options);
64+
});
6165
```
6266

67+
### Putting it all together
6368

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+
});
8684
```
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

Comments
 (0)