Skip to content

Custom callbacks allowed#18

Closed
indrimuska wants to merge 2 commits intoarschmitz:masterfrom
indrimuska:second
Closed

Custom callbacks allowed#18
indrimuska wants to merge 2 commits intoarschmitz:masterfrom
indrimuska:second

Conversation

@indrimuska
Copy link
Contributor

Perform customization of callbacks onSelect / onChangeMonthYear / beforeShow without loosing mobile style.

Demo: http://jsbin.com/indrimuska/42/edit.

Perform a customization of callbacks onSelect / onChangeMonthYear /
beforeShow without loosing mobile style.
@indrimuska indrimuska mentioned this pull request Mar 26, 2014
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are assigning a global variable in an if statement here i think what you want is to just do if( that.options[ "_" + val ]) { then below do that.options[ "_" + val ].apply( null, args );

@indrimuska
Copy link
Contributor Author

Yes, it's the same.
There are many ways to do that:

  1. Assign in the if-statement (my way):
    if ( callback = that.options[ '_'+val ] ) { callback.apply( null, args ); }
  2. Without assignment (your way):
    if ( that.options[ '_'+val ] ) { that.options[ '_'+val ].apply( null, args ); }
  3. Assignment before the if-statement:
    var callback = that.options[ '_'+val ]; if ( callback ) { callback.apply( null, args ); }

My goal is to rename user callback, i.e. onSelect, into _onSelect, and then recall the callback after to add the mobile style to the datepicker. In this way, ui-date triggers the overridden onSelect which takes care to execute addMobileStyle(); and _onSelect if set.

@arschmitz
Copy link
Owner

@indrimuska yes what your trying to do is correct but you are creating a global variable because you are not using var and we cannot create global variables. I would like the non assignment way because assignment offers no benefit here

@indrimuska
Copy link
Contributor Author

Thank you @arschmitz, I've followed your advice.

@arschmitz
Copy link
Owner

@indrimuska can you make a seperate pr for fixing the height of the days?

@indrimuska
Copy link
Contributor Author

Ok, I'll do it asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants