[Dojo-interest] Overriding dojo.dnd.Source issues

Alex Russell alex at dojotoolkit.org
Thu Aug 30 08:39:13 UTC 2007


This is truly odd. What's happening in the dojo-defined class is that 
it's setting up topic event listeners for /dnd/start, /dnd/drop, etc. 
and binding those to the local onDnDrop. Assuming that scopes work 
correctly (as they seem to on a local test page copied from 
dojo/tests/test_dnd.html (attached)), there shouldn't be any issue 
here.

Let me know if this test page doesn't demonstrate the pattern you'd like 
to see.

Regards

On Tuesday 28 August 2007 8:55 am, jduley wrote:
> Hello,
> I'm trying to override onDndDrop for dojo.dnd.Source. Here's the
> code:
>
> /////////////// contents of custom/dnd/source.js
> if(!dojo._hasResource["custom.dnd.source"]){ //_hasResource checks
> added by build. Do not use _hasResource directly in your code.
> dojo._hasResource["custom.dnd.source"] = true;
> dojo.provide("custom.dnd.source");
> dojo.require("dojo.dnd.source");
> dojo.declare("custom.dnd.Source", dojo.dnd.Source,{
> 	onDndDrop: function(source, nodes, copy){
> 		console.log("do special onDndDrop for custom.dnd.Source here");
> 	}
> });
> }
>
> ///////////  my calling app
> ...
> <script type="text/javascript" src="dojo-0.9.0/dojo/dojo.js"
> djConfig="isDebug: true, parseOnLoad: true"></script>
> <script type="text/javascript">
> 		dojo.require("custom.dnd.source");
> </script>
> </head>
> <body>
> 	<div style="float:left; margin:5px; ">
> 		<div dojoType="custom.dnd.Source" copyonly="true"
> class="container"> <div class="dojoDndItem">Div Item 1</div>
> 			<div class="dojoDndItem">Div Item 2</div>
> 			<div class="dojoDndItem">Div Item 3</div>
> 			<div class="dojoDndItem">Div Item 4</div>
> 		</div>
> 	</div>
> 	<div style="float:left; margin:5px; ">
> 		<div dojoType="custom.dnd.Source" class="container"/>
> 	</div>
> </body>
> </html>
>
> For some reason, the new version of onDndDrop in custom.dnd.Source is
> never called, but the one in dojo.dnd.Source is called.  Any idea
> what I could be doing wrong?
>
> Jason

-- 
Alex Russell
alex at sitepen.com     A99F 8785 F491 D5FD 04D7 ACD9 4158 FFDF 2894 6876
alex at dojotoolkit.org BE03 E88D EABB 2116 CC49 8259 CF78 E242 59C3 9723
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://dojotoolkit.org/pipermail/dojo-interest/attachments/20070830/387961d0/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : http://dojotoolkit.org/pipermail/dojo-interest/attachments/20070830/387961d0/attachment-0001.bin 


More information about the Dojo-interest mailing list