This isn't the problem, but it'll bite you in IE anyway:
elements: {}, << trailing coma
anyway, as to your problem, my guess is the problem is in your "attachTo"
method. Are you binding the function to your class instance?
TheWickedFlea wrote:
>
>
> Hi all.
>
> I've written a custom drop-down menu class that works great. To add
> more functionality, and the ability to dynamically manipulate
> elements, I added an "onBeforeDrop" event ... but it won't fire. I
> placed an alert within the event just in case. What am I doing wrong?
>
> Here are the relevant portions of the script:
>
> var Menu = new Class({
> Implements: [Options,Events],
> options: {
> minWidth: 150,
> wrapperClass: 'dropdownmenu',
> sizeToSender: false,
> showEvent: 'click',
> elements: {},
> // onBeforeDrop: $emptyFalse,
> },
> // Event/function happens onClick for the "item" argument.
> showMenu: function(event, item) {
> event.stop();
> //...
> this.fireEvent('beforedrop', [this.options.elements, item, this]);
> //...
> },
> }
>
> And in the <script> tags:
> window.addEvent('domready', function() {
> var links;
> var userMenu;
> if(links = $$('.userLink'))
> userMenu = new Menu({
> sizeToSender: true,
> elements: [' ?cmd=user.view&uid=0 img/
icons/icon_user.gif View Profile ',
> ' ?cmd=user.pm&uid=0 img/icons/
icon_mail.gif Private Message ']
> // tried a onBeforeDrop event here, no good.
> }).attachTo(links)
> .addEvent('beforedrop', function(elements, link, sender) {
> alert('onBeforeDrop called!');
> var temp = (/uid=(\d+)$/).exec($(link).get('href'));
> var uid = temp[1].toInt();
> $A(elements).each(function(item, index) {
> elements[index] = item.replace(/uid=(\d+)$/,'uid='+uid);
> });
> sender.rebuildMenu();
> });
> })
>
>
> Thanks for anything you might spot. If need be I'll throw together
> the full source plus an html test page. I'm considering releasing
> this to the community under an MIT license anyway. ;-)
>
> Thanks,
> Flea
>
>
-----
The MooTools Tutorial: http://www.mootorial.com www.mootorial.com
CNET Clientside: http://clientside.cnet.com clientside.cnet.com
--
View this message in context:
http://n2.nabble.com/Custom-event-isn%27t-firing.-tp1307403p1307449.html
Sent from the MooTools Users mailing list archive at Nabble.com.