File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,16 @@ selectize.off('event_name', handler);
32
32
<td valign="top">value</td>
33
33
<td valign="top">Invoked when the value of the control changes.</td>
34
34
</tr>
35
+ <tr>
36
+ <td valign="top"><code>"focus"</code></td>
37
+ <td valign="top"></td>
38
+ <td valign="top">Invoked when the control gains focus.</td>
39
+ </tr>
40
+ <tr>
41
+ <td valign="top"><code>"blur"</code></td>
42
+ <td valign="top"></td>
43
+ <td valign="top">Invoked when the control loses focus.</td>
44
+ </tr>
35
45
<tr>
36
46
<td valign="top"><code>"item_add"</code></td>
37
47
<td valign="top">value, $item</td>
Original file line number Diff line number Diff line change @@ -280,7 +280,9 @@ $.extend(Selectize.prototype, {
280
280
'option_clear' : 'onOptionClear' ,
281
281
'dropdown_open' : 'onDropdownOpen' ,
282
282
'dropdown_close' : 'onDropdownClose' ,
283
- 'type' : 'onType'
283
+ 'type' : 'onType' ,
284
+ 'focus' : 'onFocus' ,
285
+ 'blur' : 'onBlur'
284
286
} ;
285
287
286
288
for ( key in callbacks ) {
@@ -489,7 +491,8 @@ $.extend(Selectize.prototype, {
489
491
*/
490
492
onFocus : function ( e ) {
491
493
var self = this ;
492
-
494
+ var wasFocused = self . isFocused ;
495
+
493
496
self . isFocused = true ;
494
497
if ( self . isDisabled ) {
495
498
self . blur ( ) ;
@@ -500,6 +503,8 @@ $.extend(Selectize.prototype, {
500
503
if ( self . ignoreFocus ) return ;
501
504
if ( self . settings . preload === 'focus' ) self . onSearchChange ( '' ) ;
502
505
506
+ if ( ! wasFocused ) self . trigger ( 'focus' ) ;
507
+
503
508
if ( ! self . $activeItems . length ) {
504
509
self . showInput ( ) ;
505
510
self . setActiveItem ( null ) ;
@@ -517,9 +522,13 @@ $.extend(Selectize.prototype, {
517
522
*/
518
523
onBlur : function ( e ) {
519
524
var self = this ;
525
+ var wasFocused = self . isFocused ;
526
+
520
527
self . isFocused = false ;
521
528
if ( self . ignoreFocus ) return ;
522
529
530
+ if ( wasFocused ) self . trigger ( 'blur' ) ;
531
+
523
532
self . close ( ) ;
524
533
self . setTextboxValue ( '' ) ;
525
534
self . setActiveItem ( null ) ;
You can’t perform that action at this time.
0 commit comments