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); }
Solved! Go to Solution.
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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?
Views
Replies
Total Likes
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
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies