Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Javascript Behaviours for DataobjectManager Popup?

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 1798 Views
  • Anatol
    Avatar
    126 Posts

    Javascript Behaviours for DataobjectManager Popup? Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: Javascript Behaviours for DataobjectManager Popup? Link to this post

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

  • Anatol
    Avatar
    126 Posts

    Re: Javascript Behaviours for DataobjectManager Popup? Link to this post

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

    Cheers!
    Anatol

  • Capt. Morgan
    Avatar
    Community Member
    30 Posts

    Re: Javascript Behaviours for DataobjectManager Popup? Link to this post

    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?

    1798 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.