-
28 Nov 2011 12:31 AM #1
Unanswered: Open an extjs Windows on click on a html link
Unanswered: Open an extjs Windows on click on a html link
Hello everybody,
I want to open a extjs Window when I clicked on a link <a>. I have my html code like this :
Can someone tell me how I have to do with extjs 4 ?Code:'<a class="test" id="test" href="#" onClick="alert("ok");">
Thank you
-
28 Nov 2011 1:49 AM #2Ext JS Premium Member
- Join Date
- Apr 2008
- Location
- Groningen - Netherlands
- Posts
- 1,017
- Vote Rating
- 23
- Answers
- 75
Maybe sonething like below
Code:'<a class="test" id="test" href="#" onClick="javascript:openWindow(this.id);"> function openWindow(id){ Ext.create('Ext.window.Window', { title: 'Hello', height: 200, width: 400, layout: 'fit', items: { // Let's put an empty grid in just to illustrate fit layout xtype: 'grid', border: false, columns: [{header: 'World'}], // One header just for show. There's no data, store: Ext.create('Ext.data.ArrayStore', {}) // A dummy empty data store } }).show(); }
-
28 Nov 2011 2:53 AM #3
It doesn't work... Firebug told me that openwindow is not defined.
-
28 Nov 2011 2:56 AM #4Ext JS Premium Member
- Join Date
- Apr 2008
- Location
- Groningen - Netherlands
- Posts
- 1,017
- Vote Rating
- 23
- Answers
- 75
I made a typing mistake
check if the cases are right, I wrote openwindow instead of openWindowCode:'<a class="test" id="test" href="#" onClick="javascript:openWindow(this.id);">
and the function must be in scope ofcourse
-
28 Nov 2011 3:08 AM #5
It's not that, I have already correct.
I think extjs can't find my function, I put it in the scope but it doesn't work. I paste the code , it's a portal :
Code:... initComponent: function(){ function openwindow(){ alert('ok'); }; var content = '<div class="portlet-content">'+ '<section id="article18" class="crayon article-css-18 demoTime">'+ '<ul>' + '<li>' + '<a class="menuLien" href=""></a>' + '<div>' + '<h5>Title</h5>' + '<p>' + '<a class="test" id="test" href="#" onClick="openwindow();"></a>'+ '</li>' + '</ul>' + '</section>' + '</div>'; Ext.apply(this, { id: 'app-viewport', layout: { type: 'border', padding: '0 5 5 5' // pad the layout from the window edges }, items: [{ xtype: 'container', region: 'center', layout: 'border', items: [{ id: 'app-options', region: 'west', animCollapse: false, width: 1600, split: true, collapsible: false, layout: 'fit', layoutConfig:{ animate: true }, items: [{ html: content, //title:'Navigation', autoScroll: true, border: false, iconCls: 'nav' }] }, {....
-
28 Nov 2011 3:13 AM #6Ext JS Premium Member
- Join Date
- Apr 2008
- Location
- Groningen - Netherlands
- Posts
- 1,017
- Vote Rating
- 23
- Answers
- 75
Its not in scope, you have put it in the initConfig.
Then first your definition should be something like
And the callCode:this.openwindow = function(){ alert('ok'); };
Code:<a class="test" id="test" href="#" onClick="Ext.get('componentid').openwindow();"></a>
-
28 Nov 2011 5:08 AM #7
PHP Code:initComponent: function() {
var me = this;
me.items = [
{html: '<a id="test" href="#">Click Me</a>'}
];
me.on('afterrender', function () {
var aEl = Ext.get('test');
if (aEl) { aEl.on('click', me.aClick); }
}, me, {single: true});
me.callParent(arguments);
},
aClick: function () {
alert('click');
}


Reply With Quote