-1

I am trying to add the hyperlink to the Tridion ribbon by following the below code in the js file where we have isAvailable,isEnabled and _execute methods.

var mydiv = document.getElementById("myDiv");  
var aTag = document.createElement('a');
aTag.setAttribute('href',"yourlink.htm"); 
aTag.innerHTML = "link text"; 
mydiv.appendChild(aTag); 

I am able to see the hyperlink over the ribbon, but since the ribbon is refreshing for every action we do, the hyperlink is getting created multiple times(growing sideways). So i need to show only one hyperlink. Could anyone help me.

pavan
  • 451
  • 1
  • 5
  • 16

2 Answers2

6

The problem you're finding yourself in comes from trying to do things in a non-standard way. You dynamically add the elements for your custom UI control, while all other tutorials start with the declaration of the button in the the extension configuration file.

You're not the first to try this "jQuery UI extension on Tridion" approach. But there's a reason you haven't found a tutorial on it: most Tridion experts find it easier to work with the system and not against it.

Community
  • 1
  • 1
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • I have created the button using the extension.config method. I was able to create the normal button in the ribbon. But i want to create buttons one below the other similar to check-in,check-out,undo-checkout. so for that i followed the procedure of achieving through usercontrol, problem is i am able to see the buttons one below the other but they are disabled by default. So i was trying to add them dynamically. Please suggest me. – pavan Aug 10 '12 at 05:06
  • 2
    You should add all of the buttons in your user control, and associate a command with each of them. Those commands must then return a boolean in isEnabled to indicate that they should be enabled (or not) depending on some variable, such as the selected items in a list. You should not be inserting dynamic HTML in those methods. – Peter Kjaer Aug 10 '12 at 08:48
1

While I agree entirely with Frank's answer, surely the most obvious answer to your question is to not do anything until you've checked that it hasn't already been done. Yes, something as simple as using logic to determine if your code should run will do just what you need...

Jeremy Grand-Scrutton
  • 2,802
  • 14
  • 20