|
1 | 1 | /*
|
2 |
| - * jQuery Cascading Dropdown Plugin 1.2.4 |
| 2 | + * jQuery Cascading Dropdown Plugin 1.2.5 |
3 | 3 | * https://github.com/dnasir/jquery-cascading-dropdown
|
4 | 4 | *
|
5 | 5 | * Copyright 2013, Dzulqarnain Nasir
|
|
96 | 96 | response($.map(self.options.source, function(item) {
|
97 | 97 | return {
|
98 | 98 | label: item.label || item.value || item,
|
99 |
| - value: item.value || item.label || item |
| 99 | + value: item.value || item.label || item, |
| 100 | + selected: item.selected |
100 | 101 | };
|
101 | 102 | }));
|
102 | 103 | };
|
103 |
| - } else if ( typeof self.options.source === "string" ) { |
| 104 | + } else if ( typeof self.options.source === 'string' ) { |
104 | 105 | var url = self.options.source;
|
105 | 106 |
|
106 | 107 | this.source = function(request, response) {
|
|
147 | 148 | // Disable it first
|
148 | 149 | self.disable();
|
149 | 150 |
|
150 |
| - // Set selected dropdown item if defined |
151 |
| - if(!self.initialised) { |
152 |
| - self.options.selected && self.setSelected(self.options.selected); |
153 |
| - } |
154 |
| - |
155 | 151 | // If required dropdowns have no value, return
|
156 | 152 | if(!self._requirementsMet()) {
|
157 | 153 | self.setSelected(0);
|
|
229 | 225 |
|
230 | 226 | // Trigger the ready event when instance is initialised for the first time
|
231 | 227 | _triggerReady: function() {
|
232 |
| - if(!this.initialised) { |
233 |
| - this.initialised = true; |
234 |
| - this.el.triggerHandler('ready'); |
235 |
| - } |
| 228 | + if(this.initialised) return; |
| 229 | + |
| 230 | + // Set selected dropdown item if defined |
| 231 | + this.options.selected && this.setSelected(this.options.selected); |
| 232 | + |
| 233 | + this.initialised = true; |
| 234 | + this.el.triggerHandler('ready'); |
236 | 235 | },
|
237 | 236 |
|
238 | 237 | // Sets the selected dropdown item
|
|
0 commit comments