Am I missing something or is this by design? It would be really nice to programmaticly instantiate/dispose etc.. for creating a modal dialog and the other useful behaviors in the toolkit. Just for a laugh, I decided to copy over the JS files for the dropdown menu and got it working (minus some strange errors where dispose() is being called on undefined objects) but it was rather a cumbersome process having to include all the JS files and dependencies. Anyone else doing this sort of thing? Any chance there is a version of the toolkit that is not server control based?
function createDropDownMenu() { var panel = document.createElement("div"); panel.className ="ContextMenuPanel"; panel.style.display ="none"; panel.style.width ="100px"; panel.style.height ="100px"; panel.style.visibility ="hidden"; var target = $get('placeholderDiv').appendChild(panel); var dd_menu =new AjaxControlToolkit.DropDownBehavior($get('TextLabel')); dd_menu.set_dropDownControl(panel); dd_menu.set_dropDownControlID(TextLabel); dd_menu.set_dropArrowImageUrl("images/drop-arrow.gif"); dd_menu.initialize(); dd_menu.show(); }anyone?This has been requested, but it's a bit of work to create a process that will extract all the files and put them in the right dependency order, etc. It's something I'd like to do, but isn't super high-priority.
The trick to do this is as follows:
1) Get the scripts loaded by instantiating an extender and pointing it at a dummy control.
<asp:Label ID="dummy" style="display:none;"/>
<ajaxToolkit:SomeExtender TargetControlID="dummy"/>
2) Instantiate the behavior using the $create() helper, notnew
var behavior = $create(AjaxControlToolkit.SomeBehaior, {prop:value,prop2:value2}, null, null, $get('someElement'));
Excellent. This works great. Thanks for the tip!
I guess the ordering in which the scripts load has something to do with it. I modified my code to use your method and it runs cleanly now with no errors.
Good - yeah if you're okay with that little hand wave, then you don't have to worry about that stuff...
No comments:
Post a Comment