We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 39501
    • 163 Posts
    I've put together a plugin. This plugin, on a user group basis, helps restrict certain parts of a component i'm using in the MODX manager.

    It's pretty low-fi. One part of the plugin hides some buttons used by the component via CSS using:
    $modx->controller->addHTM
    


    The other part (which isn't working at the moment) loads some custom jQuery just before the closing <head> tag in the manager, using:
    $modx->controller->addLastJavascript('/assets/template/j/myScript.js');
    


    In myScript.js, as an example, I have:
    window.onload = function() {
    	jQuery(function($) {
    		$('.x-form-text').addClass('test');
    	});
    }
    


    The jQuery doesn't fire because there is no html output to manipulate, because it's being generated through ExtJs.

    Question is, is there an ExtJs version of my jQuery, that would allow me to add a class name to html markup generated in the manager?

    As you might be able to tell, I have zero knowledge in ExtJs - any tips, help, suggestions would be much appreciated.

    (You can also find me on slack if you prefer to chat in real time)

    This question has been answered by jonleverrier. See the first response.

    • discuss.answer
      • 39501
      • 163 Posts
      Thankfully, I found a way todo it with Jquery smiley Would be interested to hear if there's a different solution using ExtJS.
        • 3749
        • 24,544 Posts
        Instead of this:

        $modx->controller->addLastJavascript('/assets/template/j/myScript.js');



        Why not just

        $modx->regClientStartupScript('/assets/template/j/myScript.js');




        This might add the class (untested):

        Ext.onReady = function() {
           Ext.select('.x-form-text').addCls("test");
        }
        


          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
        • The controller methods are for the backend. The regClient methods are for the frontend (but work in the backend too - not everywhere).

          I would prefer ExtJS to do what you want. But what do you want to modify where with that code? Maybe there is a better approach, if the select code of Bob does not work.