Skip to content

Commit d56f430

Browse files
committed
introduce highlight event. fixes select2#529. fixes select2#762
1 parent 65af98c commit d56f430

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

select2.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,9 @@ the specific language governing permissions and limitations under the Apache Lic
11801180

11811181
// abstract
11821182
highlight: function (index) {
1183-
var choices = this.findHighlightableChoices();
1183+
var choices = this.findHighlightableChoices(),
1184+
choice,
1185+
data;
11841186

11851187
if (arguments.length === 0) {
11861188
return indexOf(choices.filter(".select2-highlighted")[0], choices.get());
@@ -1191,8 +1193,15 @@ the specific language governing permissions and limitations under the Apache Lic
11911193

11921194
this.results.find(".select2-highlighted").removeClass("select2-highlighted");
11931195

1194-
$(choices[index]).addClass("select2-highlighted");
1196+
choice = $(choices[index]);
1197+
choice.addClass("select2-highlighted");
1198+
11951199
this.ensureHighlightVisible();
1200+
1201+
data = choice.data("select2-data");
1202+
if (data) {
1203+
this.opts.element.trigger({ type: "highlight", val: this.id(data), choice: data });
1204+
}
11961205
},
11971206

11981207
// abstract

0 commit comments

Comments
 (0)