-
12 Jun 2012 9:48 PM #1
Unanswered: setHtml and javascript onclick function not called when checked on android and iphone
Unanswered: setHtml and javascript onclick function not called when checked on android and iphone
//And i have included a js file, which has this 'runAccordion' function,Code:Ext.define('Fxtrade.view.ClosingRates', { extend: 'Ext.Container', requires: [ current = new Date() ], alias: 'widget.ClosingRates', config: { baseCls : 'whitebg', items:[ { items:[ { xtype:'panel', layout:'card', scrollable: true, id:'thirdpanel', height:'75%', style:'background-color:white;' }, { xtype: 'formpanel', id : 'ClosingPanel' } ] }], listeners : { painted : getloadAccor } } }); function getloadAccor() { var accordionHtml= '<div id="AccordionContainer" class="AccordionContainer">'; for(var i=0; i<1; i++){ accordionHtml+='<div onclick="runAccordion(1); >\n\ <div id="closedOrder" class="AccordionTitle" onselectstart="return false;">Accordion 1</div></div>\n\ <div id="Accordion1Content" class="AccordionContent">I Am Accordion 1. </div>\n\ <div onclick="runAccordion(2);"><div class="AccordionTitle" onselectstart="return false;">Accordion 2</div>\n\ </div> <div id="Accordion2Content" class="AccordionContent">I Am Accordion 2. </div>\n\ <div onclick="runAccordion(3);"><div class="AccordionTitle" onselectstart="return false;">Accordion 3</div> </div>\n\ <div id="Accordion3Content" class="AccordionContent">I Am Accordion 3. </div>\n\ <div onclick="runAccordion(4);"><div class="AccordionTitle" onselectstart="return false;">Accordion 4</div> </div>\n\ <div id="Accordion4Content" class="AccordionContent">I Am Accordion 4. </div><div onclick="runAccordion(5);"><div class="AccordionTitle" onselectstart="return false;">Accordion 5</div> </div> <div id="Accordion5Content" class="AccordionContent">I Am Accordion 5. </div>'; } accordionHtml+='</div>'; var CurrView=Ext.getCmp('thirdpanel'); CurrView.removeAll( true, true ); Ext.getCmp('thirdpanel').setHtml(accordionHtml); }
When i checked in my desktop system, chrome browser, the function is called, and working as expected,
But when checked on device android or iphone, the fucntion is not called, the onclick event is not called.
PLEASE HELP ME TEAM, I AM LEFT WITH VERY LESS TIME,
PLEASE HELP ME ASAP.
-
14 Jun 2012 4:27 AM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,169
- Vote Rating
- 28
- Answers
- 83
Do not use onclick handlers! There is no such thing as a "click" event in mobile browsers. This is why it's not working.
What you should be doing is registering a "tap" listener via Ext.get or Ext.query.
Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
14 Jun 2012 5:20 AM #3Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 435
- Answers
- 3106
I would probably use one listener and delegate it to work with the elements you want. Here is an example:
I tried to color the mappings, the delegate event config takes in a DOM query selector, in this case, any <div> that has a class of listenToMe will fire the tap event. The element config configures the tap to work on the element of the component it is on.Code:new Ext.Container({ fullscreen : true, scrollable : true, html : [ '<div>I do not have a listener on me</div>', '<div class="listenToMe"><span>The parent div has a tap listener on it!</span></div>', '<div>I do not have a listener on me</div>', '<div class="listenToMe"><span>The parent div has a tap listener on it!</span></div>', '<div>I do not have a listener on me</div>', '<div class="listenToMe"><span>The parent div has a tap listener on it!</span></div>' ].join(''), listeners : { element : 'element', delegate : 'div.listenToMe', tap : function() { console.log('div.listenToMe was tapped on'); } } });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote