I'm trying to use Dojo (either 0.4 or 0.3.1) with the latest SVN of
MochiKit as I really like Mochi's implementation of the Scriptaculous
Sortables as well as how Mochi handles things in general. Nothing I've
tried has properly worked, giving me all imagineable sorts of errors.
Does anyone have this working? I would love to use MochiKit with Dojo
instead of having to go back and rewrite the entire app using Dojo,
just so I have access to a few Dojo widgets.
If anyone wants more specifics on anything, please post and I will
clarify as best I can.
http://developer.yahoo.com/yui/
http://www.jackslocum.com/yui/index.php
This is a known issue. The Dojo support was done a LONG time ago and
nobody has maintained it while Dojo's package system has evolved.
There's a ticket for this issue with a link to some information, but I
probably won't fix it myself because I don't know Dojo. Patches
accepted.
http://trac.mochikit.com/ticket/205
-bob
I never used sortable function area, but for general things, like
signal, DOM, XMLHTTPREQUEST, and visual effect is working fine for me.
On every our page, we always call mochi first before we call dojo
script.
I hope its can help you.
So post it here instead.
-bob
I'm no Javascript guru (nor am I all that familiar with either MochiKit
or Dojo internals), but based on the info linked, here's a
quick-and-dirty to get things up and going with Dojo .4 and the current
MochiKit CVS:
In mochikit/MochiKit/__package__.js, replace everything with the
following:
dojo.kwCompoundRequire({
"common": [
"MochiKit.Base",
"MochiKit.Iter",
"MochiKit.DOM",
"MochiKit.Async",
"MochiKit.Style",
"MochiKit.Color",
"MochiKit.Visual",
"MochiKit.Signal",
"MochiKit.DateTime",
"MochiKit.Logging",
"MochiKit.LoggingPane",
"MochiKit.Format",
"MochiKit.DragAndDrop"
]
});
dojo.provide("MochiKit.*");
***
It seems that most of the errors occur if the above aren't listed in a
particular order. I also wasn't able to get New.js or Sortable.js to
properly load when included in that list, so they must be manually
included in the file. Here's my test file and my directory structure:
./test.htm
./js/dojo/dojo.js
./js/mochikit/MochiKit/MochiKit.js
***
<html>
<head>
<script type="text/javascript" src="./js/dojo/dojo.js"></script>
<script type="text/javascript">
dojo.registerModulePath("MochiKit", "../mochikit/MochiKit");
dojo.require("MochiKit.MochiKit");
dojo.require("dojo.lfx");
</script>
<script type="text/javascript"
src="./js/mochikit/MochiKit/New.js"></script>
<script type="text/javascript"
src="./js/mochikit/MochiKit/Sortable.js"></script>
</head>
<body>
<div>
<div id="test_mochi" style="display: none;"></div>
and
<div id="test_dojo" style="display: none;"><h1>Dojo</h1></div>
</div>
<script>
MochiKit.DOM.appendChildNodes('test_mochi',MochiKit.DOM.createDOM('h1','MochiKit'));
MochiKit.Visual.appear('test_mochi');
</script>
<script>
dojo.lfx.html.wipeIn('test_dojo').play();
</script>
</body>
</html>
***
I have yet to encounter any Dojo/Mochi conflicts using this setup.
Hopefully someone more learned than I can make it into a bit more
elegant of a solution.
-Matt
I've integrated (but not tested) the __package__.js changes, but I do
not currently plan to have Sortable and DragAndDrop automatically
included with "MochiKit.*", to mirror what you get with the packed
distribution.
-bob