I'm trying to add a custom button to the sidekick that simply launches a dialog. I'm having a weird issue where the JS to add the button doesn't work (no JS errors in the console) unless I remove the content finder by removing /cf#/ from the URL. Obviously, I'm talking about author mode.
There are a number of ways to add to the sidekick. I did so by replacing the default include of init.jsp (in head.jsp) with this file, which is my own init.jsp in my page component:
Don't worry about the "isAuthor" part. We are using a framework that enables that to work, using a bean pattern. Again, this works just fine to add the button to the sidekick unless I have the content finder available. Then it fails (but doesn't error). I'm using CQ5.5, SP2 and I've reproduced this with Google Chrome and Mozilla Firefox.
Has anyone experienced this before? I wondered if this is a bug or a problem with my implementation. Anyone have an idea or a workaround?
Thanks for any help!
Solved! Go to Solution.
I'm aware of how to add a button to the sidekick. That wasn't the issue. The issue was that there was a weird inconsistency where my code worked if I had the content finder removed, but did not work if the content finder was there.
I ended up figuring out the solution, though I don't exactly know the root cause...
To make the code more extensible (I customize the sidekick in a number of places), I slightly reimplemented the init.jsp myself. Instead of adding to/using CQ.wcm.Sidekick.DEFAULT_ACTIONS, I created my own JS object, MyApp.wcm.Sidekick.ACTIONS, which gets preloaded with DEFAULT_ACTIONS, plus anything custom I need for the given page. I use this through the entire site.
In my custom init.jsp, I have to specify to use MyApp.wcm.Sidekick.ACTIONS as the list of sidekick actions, obviously so it won't use the defaults. To do so, you use the "actions" property passing in your array of sidekick actions when you call launchSidekick(). I had a typo and specified "action", not "actions" (plural).