jquery - Pass parameters to javascript functions which is bind to events -


i have function :

 var = this;  this.context.on('focus', function(i) {      var htmlelement = ele;      var style = {left: 'auto', color: '#000000'};       if(i !== null) {          = that.context.size()/2;          style.left = + 'px';          //find htmlelement in dom , apply style      } }); 

the htmlelement , style var me in different calls. need pass option such as

var options = {style: somevaue, htmlelement: somelement}

to function called multiple times different options. if pass options :

var = this; this.context.on('focus', function(i, options) {     //use options.style , options.htmlelement  }); 

it doesn't work way. doing wrong since function bind focus event of this.context has i param can't accept other param. kind of help/suggestion appreciated.

i think have worked out solution. help. here how options passed:

var = this; this.context.on('focus', function(i) {     var options = {i: i, style: somevalue, htmlelement: someelement};     that.setstyle(options); });  setstyle: function(options) {     var htmlelement = options.htmlelement;     var style = options.style;      if(options.i !== null) {         options.i = that.context.size()/2;         style.left = + 'px';         //find htmlelement in dom , apply style     } } 

please feel free comment!!!


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -