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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Javascript Behaviours for DataobjectManager Popup?


Reply

4 Posts   1827 Views

Avatar
Anatol

24 June 2009 at 12:22pm (Last edited: 24 June 2009 12:26pm), 126 Posts

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

24 June 2009 at 2:25pm 4085 Posts

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

Avatar
Anatol

24 June 2009 at 7:51pm 126 Posts

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

Cheers!
Anatol

Avatar
Capt. Morgan

4 August 2010 at 3:59am Community Member, 30 Posts

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?