Not sure what you're trying to do but you could use jQuery instead of
mootools, it also uses $ as a function but there's an easy way to put it
back, eg for jQuery replace $() with jQuery(). It's something like
jQuery.no_conflict() as I recall.
Matteo Pelucco wrote:
Hi all,
I'm using Mootools as JS framework. Mootools is not scoped, so it
defines $ as a function. But it should not be a problem, because
Magnolia defines its own $ function with these lines:
*****************************
if (typeof $ != 'function') {
function $(element)
{
return document.getElementById(element);
}
}
*****************************
I'am a bit confused: this piece of code
*****************************
...(head with mootools js declaration)
<body ${bodyID} ${bodyClass}>
<script type="text/javascript">
alert($);
alert(typeof $);
</script>
[#-- add Magnolia css and js: --]
[...@cms.links /]
<script type="text/javascript">
alert($);
alert(typeof $);
</script>
...
*****************************
produced the following alert in IE7 // Chrome // Safari
1) <mootols $ function>
2) function
3) <magnolia $ function>
4) function
but in Firefox
1) <mootols $ function>
2) function
3) <mootools $ function>
4) function
Why this?
The only way to let Magnolia & Mootols (but I think it is also with
other $-based-not-scoped js libs) is to replace
*****************************
[#-- add Magnolia css and js: --]
[...@cms.links /]
*****************************
with
*****************************
[#-- add Magnolia css and js: --]
[...@cms.links /]
[#-- Mootools 1.2.4 HACK, because Magnolia redefines $ function --]
<script type="text/javascript">
$ = function (a, b) {
return document.id(a, b, this.document);
}
</script>
*****************************
PS: why not use something like "mgnl" as $ replacement?
Matteo
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscr...@magnolia-cms.com>
----------------------------------------------------------------
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscr...@magnolia-cms.com>
----------------------------------------------------------------