javascript - Object # has no method addEventListener -



javascript - Object #<Controller> has no method addEventListener -

i trying create controller create switch button android since 1 in titanium doesn't have de holo android need, controller working fine, there addeventlistener in controller uses switch controller that's throwing me object #<controller> has no method addeventlistener error. told me had define addeventlistener method in switch controller have no clue how this. ideas?

customer.xml:

... <view> <switch id="myswitch" platform="ios"/> <require id="myswitch" platform="android" src="customswitch" /> </view> ...

customer.js:

... $.myswitch.addeventlistener('change', function(e) { // magic goes in here }); ...

customswitch.js:

$.value = false; $.setvalue = function(value){ $.value = value; } var switchbutton = ti.ui.createbutton({ width : 97, height : 24, backgroundimage : '/images/ic_switch_on.png', visible : true }); switchbutton.applyproperties($.container.switchbutton); $.container.add(switchbutton); $.container.addeventlistener('click', function(evt){ $.onclick && $.onclick({}); var currentvalue = $.value; if (currentvalue) { switchbutton.backgroundimage = '/images/ic_switch_off.png'; $.setvalue(!currentvalue); } else { switchbutton.backgroundimage = '/images/ic_switch_on.png'; $.setvalue(currentvalue); } });

you trying set event listener on container object. wanted add together event listener switchbutton created , added container:

switchbutton.applyproperties($.container.switchbutton); switchbutton.addeventlistener('click', function(evt){ $.onclick && $.onclick({}); var currentvalue = $.value; if (currentvalue) { switchbutton.backgroundimage = '/images/ic_switch_off.png'; $.setvalue(!currentvalue); } else { switchbutton.backgroundimage = '/images/ic_switch_on.png'; $.setvalue(currentvalue); } }); $.container.add(switchbutton);

javascript android titanium titanium-mobile titanium-alloy

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -