0

I'm trying to make a box to select different options and proccess its information. I want to get a result like this:

box

It's a jQuery plugin called jQuery Select2

I was seeing that it isn't contentEditable div, it has only a tabindex with "-1" value to can focus this element.

I was looking for an answer but I found only about contentEditable elements or inputs or textareas

I want to set the caret position to the end after it gets focused.

Here's my JSFiddle:

$(document).ready(function () {
    $('#selector').on('focus', function () {
        //..some code to pos the caret
    });
});

I was thinking on something like that

Sunny Patel
  • 7,830
  • 2
  • 31
  • 46
r3ivaj
  • 1
  • Well it is sort of hard to add a cursor when you cannot actually edit it.... – epascarello May 12 '14 at 18:56
  • Ohh, yes, I was thinking the same, I'd like to just remove each block of "li" tags but when I make the div "contentEditable" and I press the backspace it removes letter by letter and not the entire "li". But first at all I don't know how jQuery Select2 set the caret position if the div boxes aren't contentEditable ? thanks for your answer :) – r3ivaj May 12 '14 at 19:05
  • You know there are libraries that already do this... http://stackoverflow.com/questions/2531255/jquery-tag-editor – epascarello May 12 '14 at 19:27
  • Oh, now I have more ideas to do that :) thank you! – r3ivaj May 12 '14 at 20:30
  • Why would you want a cursor, when the whole thing looks like a very nice, clickable element? – TimSPQR May 12 '14 at 20:34
  • It's because I want a search form to add tags with preload data but I'll fixt it putting an input at the end :D – r3ivaj May 12 '14 at 21:13

0 Answers0