Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

Javascript Behaviours for DataobjectManager Popup?


Go to End


4 Posts   2042 Views

Avatar
Anatol

126 Posts

24 June 2009 at 12:22pm

Edited: 24/06/2009 12:26pm

Hi,

I'm trying to add a JavaScript behaviour to the DataobjectManager Popup like this:

Behaviour.register({
	'#DataObjectManager_Popup_DetailForm_MediaType': {
		onchange: function() {
			alert('changed'); // more useful code here
		},
		initialize: function() {
			this.onchange();
		}
	}
});

I'm not quite sure where to add the JavaScript file:

Requirements::javascript('mysite/javascript/eventbehaviours.js');

After some failed attempts I added it to the DataObjectManager_Popup class in DataObjectManager.php and at least I get an error message that says: "Behaviour is not defined". Where do I need to add the required JavaScript file? I guess the problem is that it has to come after /jsparty/behaviour.js but wherever I put it it appears earlier in the HTML code.

Cheers!
Anatol

Avatar
UncleCheese

Forum Moderator, 4102 Posts

24 June 2009 at 2:25pm

DataObjectManager doesn't work with the Behavior class, so it gets blocked. You'll have to assign the behaviors using JQuery.

Avatar
Anatol

126 Posts

24 June 2009 at 7:51pm

Thanks Uncle Cheese! I really appreciate your support and fantastic modules.

Cheers!
Anatol

Avatar
Capt. Morgan

Community Member, 30 Posts

4 August 2010 at 3:59am

I'm curious about where I should add the javascript if I don't want to go in and mess with the code in the DOM module?