I have a TabPanel with 8 tabs, and when I click a particular tab panel, I want to create an event. I have tried using the "onClientClick" but it throws an error.
So you can handle the select event (click the events tab for the docs) from the tab and in that event handler you can raise your own custom event with
trigger.
So "TabContainer" is obvioulsy the name of the TabContainer. Is "myTag" the name of the TabPanel, and the is myCustomEvent the name of a javascript function being called?
"myTag" is just the ID of the element from which you want to raise this custom event -- this could be the tab container or any other element in the page that is the source of the event. Again, it's custom so you have to decide where this event is coming
from.
"myCustomEvent" is just the name of your event. It's sort of like "click" or "mouseover" or "select" (for the tabs). It's just a name for an event and since it's custom you get to decide what it's going to be called. Also, I think the thing you're missing
is that raising an event is different than handling the event. This sample so far is only raising the event -- it doesn't show another piece of code handling the event. That's then done with
bind.
$("#myTag").bind("myCustomEvent", function() {
});
The cool thing is that the listener code doesn't have to bind directly to your tag (the source of the event) -- if the code is sufficiently decoupled then it could register to a parent element:
JAYHAWKER
Participant
1252 Points
1896 Posts
I want to create an event when clicking a TabPanel in a Tab Container, how do I do that?
Apr 15, 2012 03:41 PM|LINK
I have a TabPanel with 8 tabs, and when I click a particular tab panel, I want to create an event. I have tried using the "onClientClick" but it throws an error.
How cand I do it?
BrockAllen
All-Star
27522 Points
4901 Posts
MVP
Re: I want to create an event when clicking a TabPanel in a Tab Container, how do I do that?
Apr 15, 2012 03:44 PM|LINK
So you can handle the select event (click the events tab for the docs) from the tab and in that event handler you can raise your own custom event with trigger.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
JAYHAWKER
Participant
1252 Points
1896 Posts
Re: I want to create an event when clicking a TabPanel in a Tab Container, how do I do that?
Apr 15, 2012 03:49 PM|LINK
Thanks Can you give me an example?
BrockAllen
All-Star
27522 Points
4901 Posts
MVP
Re: I want to create an event when clicking a TabPanel in a Tab Container, how do I do that?
Apr 15, 2012 03:50 PM|LINK
$("#tabContainer").tabs({
select : function() {
$("#myTag").trigger("myCustomEvent");
}
});
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
JAYHAWKER
Participant
1252 Points
1896 Posts
Re: I want to create an event when clicking a TabPanel in a Tab Container, how do I do that?
Apr 15, 2012 04:00 PM|LINK
Thanks. Very close now.
So "TabContainer" is obvioulsy the name of the TabContainer. Is "myTag" the name of the TabPanel, and the is myCustomEvent the name of a javascript function being called?
BrockAllen
All-Star
27522 Points
4901 Posts
MVP
Re: I want to create an event when clicking a TabPanel in a Tab Container, how do I do that?
Apr 15, 2012 04:11 PM|LINK
"myTag" is just the ID of the element from which you want to raise this custom event -- this could be the tab container or any other element in the page that is the source of the event. Again, it's custom so you have to decide where this event is coming from.
"myCustomEvent" is just the name of your event. It's sort of like "click" or "mouseover" or "select" (for the tabs). It's just a name for an event and since it's custom you get to decide what it's going to be called. Also, I think the thing you're missing is that raising an event is different than handling the event. This sample so far is only raising the event -- it doesn't show another piece of code handling the event. That's then done with bind.
$("#myTag").bind("myCustomEvent", function() {
});
The cool thing is that the listener code doesn't have to bind directly to your tag (the source of the event) -- if the code is sufficiently decoupled then it could register to a parent element:
$("body").bind("myCustomEvent", function() {
});
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
JAYHAWKER
Participant
1252 Points
1896 Posts
Re: I want to create an event when clicking a TabPanel in a Tab Container, how do I do that?
Apr 15, 2012 04:18 PM|LINK
Thank you very much. I may have some more questions for you in a followup but I marked all of them so far as answered.
Thanks again!