@@ -290,28 +290,32 @@ angular.module('ui.jq',[]).
290290
291291 return function uiJqLinkingFunction ( scope , elm , attrs ) {
292292
293- var linkOptions = [ ] ;
294-
295- // If ui-options are passed, merge (or override) them onto global defaults and pass to the jQuery method
296- if ( attrs . uiOptions ) {
297- linkOptions = scope . $eval ( '[' + attrs . uiOptions + ']' ) ;
298- if ( angular . isObject ( options ) && angular . isObject ( linkOptions [ 0 ] ) ) {
299- linkOptions [ 0 ] = angular . extend ( { } , options , linkOptions [ 0 ] ) ;
300- }
301- } else if ( options ) {
302- linkOptions = [ options ] ;
303- }
304293 // If change compatibility is enabled, the form input's "change" event will trigger an "input" event
305294 if ( attrs . ngModel && elm . is ( 'select,input,textarea' ) ) {
306295 elm . bind ( 'change' , function ( ) {
307296 elm . trigger ( 'input' ) ;
308297 } ) ;
309298 }
310299
300+ function createLinkOptions ( ) {
301+ var linkOptions = [ ] ;
302+
303+ // If ui-options are passed, merge (or override) them onto global defaults and pass to the jQuery method
304+ if ( attrs . uiOptions ) {
305+ linkOptions = scope . $eval ( '[' + attrs . uiOptions + ']' ) ;
306+ if ( angular . isObject ( options ) && angular . isObject ( linkOptions [ 0 ] ) ) {
307+ linkOptions [ 0 ] = angular . extend ( { } , options , linkOptions [ 0 ] ) ;
308+ }
309+ } else if ( options ) {
310+ linkOptions = [ options ] ;
311+ }
312+ return linkOptions ;
313+ }
314+
311315 // Call jQuery method and pass relevant options
312316 function callPlugin ( ) {
313317 $timeout ( function ( ) {
314- elm [ attrs . uiJq ] . apply ( elm , linkOptions ) ;
318+ elm [ attrs . uiJq ] . apply ( elm , createLinkOptions ( ) ) ;
315319 } , 0 , false ) ;
316320 }
317321
0 commit comments