Jump to:

17452 Posts in 4473 Topics by 1971 members


SilverStripe Forums » Archive » Onchange event in CMS

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1371 Views
  • UncleCheese
    4085 Posts

    Onchange event in CMS Link to this post

    I'm trying to unobtrusively attach an onchange event to a select box on my CMS page. I've figured out that i can add custom script to a specific module using the augmentInit() function off the DataObjectDecorator.

    What's confusing to me is that the window.onload() event seems to fire when the silverstripe logo comes up, which is before my select box is loaded into the DOM.

    Anyone know how this is usually done?

  • ajshort
    Community Member
    244 Posts

    Re: Onchange event in CMS Link to this post

    Hi UncleCheese,

    something like this is normally used:

       'select.domSelector' : {
          initialize: function () {
             // etc
          onclick: function() {

    Not only will this get applied on page startup, but itll also be reapplied whenever a page is loaded using AJAX.

  • UncleCheese
    4085 Posts

    Re: Onchange event in CMS Link to this post

    Perfect! What a great solution. So glad I posted here. I was sure no one would have an answer!

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.