views:

43

answers:

2

How can I add a button to jwysiwyg that will add an HTML tag to the selected text? I tried this, based on the documentation:

$('#wysiwyg').wysiwyg({
    controls: {
       tt: { visible: true, tags: ['tt'], css: { class: 'tt', className: 'tt' } }
    }
})

... And it adds the button, all right, but then the button doesn't seem to actually do anything. I select some text, click on it, and nothing happens. Any ideas?

A: 

follow up question, how to clear the value of the wysiwyg?

vrynxzent
A: 

You can add a button and specify the 'exec' property, like so:

$('#wysiwyg').wysiwyg({
    controls: {
       tt: { 
             visible: true, 
             tags: ['tt'], 
             css: { class: 'tt', className: 'tt' }, 
             exec: function(){
                  //Do Something
                }
            }
    }
});

with $('#wysiwyg').wysiwyg('setContent', '') you can clear the textarea.

tomvo