How to make a button become gray(disable) in sidekick | Community
Skip to main content
October 16, 2015
Solved

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

  • October 16, 2015
  • 3 replies
  • 1128 views

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); }
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Daniel_Gordon

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

3 replies

Daniel_Gordon
Adobe Employee
Daniel_GordonAdobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

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

October 16, 2015

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? 

Daniel_Gordon
Adobe Employee
Adobe Employee
October 16, 2015

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