Question

I'm trying to open the hallo editor toolbar on document.ready with focus on the first element or anywhere, it doesn't really matter I just need to open it

I tried triggering a click event on the editable element, and a focus event, nothing worked. I have also tried to put the caret in the editable element:

var el = document.getElementById("content");
var range = document.createRange();
var sel = window.getSelection();
range.setStart(el.firstChild, 2);
range.collapse(true);
sel.removeAllRanges();
sel.addRange(range);

any other ideas?

Was it helpful?

Solution

I got it, must insert the caret in the element and then trigger the event halloactivated on document.ready

   var range = rangy.createRange();
   var sel = rangy.getSelection();
   range.selectNode(el);
   sel.removeAllRanges();
   sel.addRange(range);

   jQuery('#content').trigger('halloactivated');    
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top