Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!
SOLVED

How to make a button become gray(disable) in sidekick

Avatar

Former Community Member

I add a new button into sidekick. Assume there is a variable to control this button (not)gray in sidekick, but how to make it? Anyone know that, please comment on that.Thanks a lot!

 

addToCart: function(sk){ var pagePanel = sk.panels["PAGE"]; var button = pagePanel.findBy(function(comp){ return comp["name"] == "ADD2_CART"; }, pagePanel); if(button && button.length > 0){ return; } button = { xtype: "button", scope: sk, name: "ADD2_CART", text: "Add to cart", "context": [ CQ.wcm.Sidekick.PAGE ], handler: function(){ //store to cart var pagePath = CQ.WCM.getPagePath(); var params = {"nodePath": pagePath}; CQ.HTTP.post("/bin/mySearchServlet", function(options, success, response) { if (!success) { CQ.Ext.Msg.alert( CQ.I18n.getMessage("Error"), CQ.I18n.getMessage("Could not add current page to cart.")); } else { CQ.Ext.Msg.alert("Success","Current Page has been put into cart"); } },params); } }; pagePanel.insert(10,button); sk.actns.push(button); }
1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

I believe the property to start the button as disabled is a variable called 'disabled' that accepts a boolean value, (defaults to false) . Please see the widget api for more info: http://docs.adobe.com/docs/en/cq/current/widgets-api/index.html

[ CQ.wcm.Sidekick.DELETE, CQ.wcm.Sidekick.CUSTOM_BTN, { text: "Custom Action", handler: ...,disabled: (true or false) }, CQ.wcm.Sidekick.PROPS ]

To disable/enable the button after it has been initialized use disable() / enable() methods

View solution in original post

3 Replies

Avatar

Correct answer by
Employee Advisor

I believe the property to start the button as disabled is a variable called 'disabled' that accepts a boolean value, (defaults to false) . Please see the widget api for more info: http://docs.adobe.com/docs/en/cq/current/widgets-api/index.html

[ CQ.wcm.Sidekick.DELETE, CQ.wcm.Sidekick.CUSTOM_BTN, { text: "Custom Action", handler: ...,disabled: (true or false) }, CQ.wcm.Sidekick.PROPS ]

To disable/enable the button after it has been initialized use disable() / enable() methods

Avatar

Former Community Member

hi D, you answer help and work. But here another question: if the true or false up to a result that invoke OSGI bundle java function, how to write that code in the JS block? 

Avatar

Employee Advisor

It sounds like you need to perform an ajax call. You could expose the java function as a servlet and call it via javascript. Although this sounds like quite a lot of customization...

http://blogs.adobe.com/aaa/2012/09/cq-tips-and-tricks-1-how-to-define-a-slingservlet-cq5-5-5-6.html