0

I have this component in ExtJS to which I am setting some HTML and there is an onclick inside it that I have to call. So How do I call a javascript function from HTML of an Extjs component

This is my code:

for the component:

  collapsed: true,
                    layout: 'fit',
                    items: [
                        {
                            xtype: 'component',
                            itemId: 'requirementHeaderViewID-' + i,
                            html: arrReqTplTest

                        }
}
);

This is the HTML:

arrReqTplTest = ['<div class="wrap-req"><table><tr><th class="wrap-req">' +
                'NAME  ' +
                '<img src="resources/images/arrow-bottom-1-512.png" width="10px" height="10px" onclick="{[this.sortStore();]}"/>' +
                '</th><th class="wrap-req">CATEGORY ' +
                ' <img src="resources/images/arrow-bottom-1-512.png" width="10px" height="10px" onclick="sortStore();"/>' +</th>'</table>',
                </th></tr></table></div>

This is the function lets say:

sortStore: function(){
alert('xyz');
}

I have shortened the code for your ease, so might have syntax errors but rest assured everything fine but I just need to know how to call a JS function from HTML that is part of Ext.JS component after the page is loaded.

Nick Div
  • 5,338
  • 12
  • 65
  • 127
  • How you "call" a Javascript function is often by reacting to an event, such as a click. Is that what you want? To know how to invoke a function by clicking on the div defined by the HTML? If so, have a look at some steps I list in this answer: http://stackoverflow.com/a/12287732/34806 – Dexygen Apr 14 '14 at 15:05
  • Check out my answer http://stackoverflow.com/questions/23061763/javascript-undefined-is-not-a-functio/23065128#23065128 . The answer is for sencha touch but is also applicable to ExtJS. – Abhi Apr 14 '14 at 16:23
  • @Abhi I like you r jsfiddle. Let me see how can I put it in my code. Thank you, will let you know once I try it. – Nick Div Apr 14 '14 at 17:33
  • @Abhi That other question is also posted by me. – Nick Div Apr 14 '14 at 17:35

0 Answers0