0

I have installed a managed package that has a static resource (JS). This static resource performs a jQuery "prepend" to show a button. I cannot change the code of this static resource but i have the ability to create another static resource (JS) and write some code for customizations. The thing is: a Visualforce page is loaded (i have no access to the VF Page code) and then my custom static resource is loaded and then the managed package static resource is loaded. Their static resource, performs a prepend on a button, but i want this button to always be hidden. But, although i add the command to hide the button, it is not. I suppose it's because the button is loaded after my command... Has anyone face this problem again? Is there a way to solve it?

Code below: Managed package static resource code that performs the "prepend"

jQuery(buttons[0]).prepend('<button id="addonman" class="slds-button slds-button--neutral">Add On Manager</button>');
jQuery('#addonman').click(showFullManager)

My static resource

CS.EventHandler.subscribe(CS.EventHandler.Event.AFTER_SHOW_SCREEN_ACTION, function (payload) {
//? Test functionality...
      jQuery("#addonman").hide();
});
  
2
1

Assuming it needs to be JavaScript, just add a CSS rule:

CS.EventHandler.subscribe(CS.EventHandler.Event.AFTER_SHOW_SCREEN_ACTION, 
function (payload) {
//? Test functionality...
      document.styleSheets[0].insertRule("#addonman { display: none; }");
});

By adding it as a rule, you can technically do it whenever you want, even before the button is rendered into the page.

If you can choose to import CSS, you can just make it a rule:

#addonman {
  display: none;
}
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.