-
1 Nov 2006 10:01 AM #1
change a div when onclick event a tab of a content panel
change a div when onclick event a tab of a content panel
wow.. what title!!!
so..
i have my contentpanel:
now i would like to link a function when u click on the tab named tab, so that i can update a div..Code:layout.add(..); .... layout.add('center', new YAHOO.ext.ContentPanel('center3', {title: 'Forum', closable: true}));
something like this:
this don't show 123 when i click on forum label tab, i would likeCode:layout.add('center', new YAHOO.ext.ContentPanel('center3', {title: 'Forum', closable: true, onclick: function(){alert(123)}}));
-
1 Nov 2006 2:46 PM #2
Jack may chime in with another solution here, but rather than look for an 'onclick', you could look for the 'activate' event. This is only going to fire on the 1st click, because once a tab is activated, clicking again doesn't really mean anything, unless you click on sub-element of the tab that handles a click, and then bubbles it all the way up to the tab.
get a ref to your panel, then
Code://this needs to happen after the panel is added to the region, otherwise it will fire one time //immediately b/c the tab is activated upon add. panel.on('activate', myfunc, this, true); ... function myfunc(panel, obj) { alert('123'); }Tim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide
-
1 Nov 2006 10:07 PM #3
That's exactly what I would have suggested.

-
2 Nov 2006 12:29 AM #4
ok..
it's so simple... but it don't work.. i did this:
also adding the " to function arg name it don't wont to work.. what i wrong?Code:layout.add('center', new YAHOO.ext.ContentPanel('center3', {title: 'Forum', closable: true})); layout.getRegion("center").getPanel("center3").on("activate",act3,this,true); function act3(panel,obj){alert(123)}
ps: is there a documentation for borderLayout?
-
2 Nov 2006 12:38 AM #5
This is pretty much the same situation I've just been in. Have a look at the advice Jack offered to me as this worked great:
http://www.jackslocum.com/forum/viewtopic.php?t=444
-
2 Nov 2006 12:55 AM #6
hi, thx for the reply
i have read, but nothing changed,it give me error in js console saying that "this.events is not defined"
i used this code:
Code:Example = function(){ return { init : function(){ [....] // omissions to shorten the code :p layout.add('center', new YAHOO.ext.ContentPanel('center3', {title: 'Forum', closable: true})); layout.getRegion("center").getPanel("center3").on("activate",Example.act3,Example,true); layout.getRegion('center').showPanel('content'); layout.endUpdate(); }, act3 : function(){ alert('test'); } } }(); YAHOO.ext.EventManager.onDocumentReady(Example.init, Example, true);
-
2 Nov 2006 1:45 AM #7
What version are you using? The latest beta? Can you put a link up somewhere? I see nothing obvious in your code so it has to be a weird issue. That event works though, I use it extensively.
-
2 Nov 2006 2:12 AM #8
jack, i know i'm your worse incubus.. :roll:
so...
this is the page to obtain:
http://fantaluke.net/sc/test/correct.htm
and this is the page with code for the "onActivate" event:
http://fantaluke.net/sc/test/test.htm
i'm in your hands...
as usual.. :lol:
-
2 Nov 2006 8:10 AM #9
You might try splitting this line and see if you really have a ref to your panel
This is the issue I initially had - you're creating a panel with a title='center3', not id='center3'. getPanel is looking for an id, not a title (at least in this beta).Code:layout.getRegion("center").getPanel("center3").on("activate",Example.act3,Example,true); var p = layout.getRegion("center").getPanel("center3");
I didn't try this with your code, but it's basically how I got around it in my code:
Note also that if you add the event to the panel before you add the panel to the layout, the event will fire once immediately. This is b/c activate is fired upon add - this may or may not be what you want.Code:var p = new YAHOO.ext.ContentPanel('center3', {title: '[img]images/tforum.gif[/img] Forum', closable: true}); layout.add('center', p); p.on('activate', Example.act3,Example,true);Tim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide
-
2 Nov 2006 8:39 AM #10
thx a lot for reply but i have no result trying your code.. :? u can see it in test.htm.. :cry: nathing to do..

Similar Threads
-
"onclick" event for Datefield
By DrZog in forum Ext 1.x: Help & DiscussionReplies: 5Last Post: 26 Mar 2007, 4:26 PM -
How to Dynamically change the content of a BorderLayout.
By wq7278 in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 7 Mar 2007, 7:35 AM -
Updating content panel.
By joxan in forum Ext 1.x: Help & DiscussionReplies: 3Last Post: 2 Mar 2007, 11:58 PM -
tabpanel - how change content
By rudy in forum Ext 1.x: Help & DiscussionReplies: 7Last Post: 20 Feb 2007, 6:31 AM -
Splitbar: Change height according to content
By Dextro in forum Ext 1.x: Help & DiscussionReplies: 3Last Post: 4 Dec 2006, 6:55 AM


Reply With Quote