Hello again !
I'm trying to setup a function call on this event because I have to manipulate some markup at menu display time.
I tried this code :
Drupal.behaviors.MyBehaviour = {
attach: function(context, settings) {
$('#superfish-1').superfish('onBeforeShow', function() {
alert('onBeforeShow ok');
});
}
}
... which works but seems to mess up the other init options (drop shadows back despite the fact they are disabled in config). I suspect it resets everything to default.
So my quesiton is : is there a way to add or change an option after the menu has been initialized, or should I setup my own intialisation functionwith all the options I need ?
The first solution would be a lot more convenient, but I couldn't find any working example on the net, so I'm asking the local expert ;-).
Comments
Comment #1
Countzero commentedSpoke too soon : in fact it doesn't work at all.
Comment #2
mehrpadin commentedBonjour,
You can use the "supposition.js" as a reference:
Comment #3
Countzero commentedThank you but I don't get it. How am I supposed to call this code afterwards ?
OnBeforeShow is a standard superfish option, supposed to fire a callback before showing any ul element in the menu.
I don't see why it should be necessary to extend the existing plugin to handle this.
Comment #4
Countzero commentedI ran this on a non superfish block menu and it behaves as expected.
I guess what I'd need is a setter function for the superfish options, but there are not, right ?
As my menu won't change a lot once configured, I'll stick with this mildly satisfying solution.
I don't know if it's of any use for you to leave this issue open.
As far as I'm concerned, and except if you come up with a cleaner way to do it (mean : not bypassing your module's great functionalities), we can close this.
Thanks
Comment #5
mehrpadin commentedMon ami, I think I've an idea, added to my to-do list for the next version.
Comment #6
sagannotcarl commentedHere is a patch that provides fields on the block settings form to add custom onBeforeShow, onShow, and an onHide functions.
You can put whatever javascript you want in those fields. It solves a short-term need I have but I'm sure this is a security problem if you have untrusted users with administer block permissions.
Any thoughts on how to allow this kind of thing to happen without running javascript directly from a user?
Comment #7
mehrpadin commentedThe patch - or the feature - cannot be added due to security & stability issue, those requiring this feature can add sub-plugins like advised above :)