We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14883 ☆ A M B ☆
    • 450 Posts
    I am trying to follow the CMP tutorial/example; I created my Namespace, Controller file, Action and Menu Object. In my Controller file I’m including a js file like this:
     $modx->regClientStartupScript('/assets/components/widget_hilite/js/hilite.js');
    return 'This is my first Custom Manager Page';


    My .js file is responsive - when I put a simple "alert()" statement in it, it works. But when I try to use MODExt.Mst.alert, it throws an error.
    MODx.Msg.alert('Warning!','You are out of space! We should clear the cache.',function() {
      MODx.clearCache();
    },MODx);


    "Uncaught TypeError: Object function (A){A=A||{};MODx.Msg.superclass.constructor.call(this,A);this.addEvents({success:true,failure:true,cancel:true});Ext.MessageBox.minWidth=200;} has no method ’alert’"

    Am I missing a necessary step for using MODExt?
      • 28215
      • 4,149 Posts
      MODx.msg.alert


      with a lowercase ’m’ in msg. JS is case-sensitive, in this sense.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 14883 ☆ A M B ☆
        • 450 Posts
        Quote from: splittingred at May 26, 2011, 10:57 AM

        MODx.msg.alert


        with a lowercase ’m’ in msg. JS is case-sensitive, in this sense.

        1. I took that code directly from the MODx.Msg RTFM page (http://rtfm.modx.com/display/revolution20/MODx.Msg)
        2. When I change it to lower-case I still get an error, albeit a different one:
        Uncaught TypeError: Object #<Object> has no method 'alert'
          • 28215
          • 4,149 Posts
          I’ve fixed the docs. Thanks for catching that!

          Where are you putting the code? You’ll need to make sure to do it *after* MODx.msg loads, so at the very least wrap it in a Ext.onReady clause:

          Ext.onReady(function() {
              MODx.msg.alert('Warning!','You are out of space! We should clear the cache.',function() {
                MODx.clearCache();
              },MODx);
          });
          
            shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
            • 14883 ☆ A M B ☆
            • 450 Posts
            That works. I was just putting it in using $modx->regClientStartupScript() according to the recommendation on the "Scripts and CSS" section on the CMP page (http://rtfm.modx.com/display/revolution20/Custom+Manager+Pages)

            I guess just like with jquery, you need to wrap most of it in an onready statement in order to ensure that everything is properly loaded(?)
              • 28215
              • 4,149 Posts
              Quote from: jrotering at May 26, 2011, 11:17 AM

              I guess just like with jquery, you need to wrap most of it in an onready statement in order to ensure that everything is properly loaded(?)
              Yep.
                shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com