2012年3月10日土曜日

Running javascript after collapse/expand?

Seehttp://forums.asp.net/t/1112899.aspx

-Damien


Yeah, thanks, I saw that post. It didn't help me any. The events don't seem to want to register, or something. The function I'm calling never fires when the panel expands/collapses. Is it safe to assume that the collapsiblePanelExtender is what's actually firing the event? Or is the ControlId I have it wired to? May be able to figure it out if I knew that.

Also, was the intention to actually have two 'add's on the collapse event? VS wouldn't accept that, but took it with just one.


It's probably when you are calling the events that is the issue. Try registering the script using theClientScriptManager.RegisterStartupScript which will render it at the end of your page.

Those events are fired by the the Panel's "Behavior" (hence why you have to use $find() vs $get())

The extra add in that code was incorrect, you are correct...

-Damien


That knowledge helps out substantially. I figured out how to get the handlers to work, thanks to you.

However, there are multiple instances of objects with the same behaviorID. Is there any way to tell which behaviorID is throwing the event? I tried to get the parent of the behavior hoping it would be the panel surrounding the collapsibleExtender, but I guess that it's not really an object, and not in the flow of the page, huh? If I could get the ID of the object which the component belongs to I'd be set. Any ideas? Thanks ever so much!


You should be able to call .get_element() on the behavior object.

For example:

var behavior = $find(...);
var domElement = behavior.get_element();

-Damien


Wow... I feel quite sheepish now... I don't know why I didn't think of that... Thank you so much, Damien. You are a scholar among men.

0 件のコメント:

コメントを投稿