javascript - How to validate input parameters of a jQuery widget factory before initialize the widget with them? -


is there way validate input parameters of jquery widget factory before initialize widget options them?

i want prevent incorrect parameters , use default options instead of them.

something this:

$.widget( "custom.colorit", {      options: {         color: 'red'     },      _create: function(opts) {       //<< opts not working here          var validatedoptions == this._validateoptions(opts);          // merge default options validated options         this.options= $.extend(this.options,validatedoptions);          this.element.text( this.options.color );     },      _validateoptions: function( opts ) {             if(opts.color =='green')                 opts.color='blue';            if(opts.color =='black')                 opts.color= undefined;            return opts;                         } }); 


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -