javascript - outer jquery draggable/resizable div's not allowing me to select text of inner span -
i have dynamically created jquery draggable div, has nested jquery resizable div within it.
inside resizable div have nested span text inside.
i can drag div , resize it.
i want able select text within span parent divs blocking me doing it.
i can click on text , call alert still cannot highlight text.
am missing obvious?
i have created jsfiddle can see in action.
you can resize , drag box around , if click on text alert, cannot select text
any appreciated tearing hair out
heres code javascript
function createtextbox(i, id, top, left, width, height, content,zindex,borderwidth,borderstyle,bordercolor,padding) { id = id + i; var newdiv = document.createelement('div'); newdiv.setattribute('id', id); newdiv.setattribute('class', 'dragbox'); newdiv.setattribute('iterate', i); newdiv.style.position = "absolute"; newdiv.style.top = top + "px"; newdiv.style.left = left + "px"; newdiv.style.borderwidth = "1px"; newdiv.style.cursor = 'move'; newdiv.style.zindex = zindex; newdiv.innerhtml = "</div><br><div id='div" + + "' name='textarea[" + + "]' class='textarea1' style='padding:"+padding+"px; border-width:"+borderwidth+"px; border-style:"+borderstyle+"; border-color:"+bordercolor+"; width:"+width+"px; height:"+height+"px;position:absolute; top:10px;left:0px;overflow-y: none;background-color:transparent;'><span id='span" + + "'>" + content + "</span></div>"; var htmldata = $('#' + i).html(); newdiv.innerhtml = newdiv.innerhtml + "<br><input name='contents[" + + "]' type='hidden' value='" + content + "'/>"; newdiv.innerhtml = newdiv.innerhtml + "<br><input type='hidden' value='" + + "' name='id[" + + "]'><br><input name='box_type[" + + "]' type='hidden' value='text'/>"; newdiv.innerhtml = newdiv.innerhtml + "<br><input type='hidden' value='" + width + "' name='width[" + + "]' id='width" + + "'><br><input type='hidden' value='" + height + "' name='height[" + + "]' id='height" + + "'>"; newdiv.innerhtml = newdiv.innerhtml + "<br><input type='hidden' value='" + left + "' name='left[" + + "]' id='left" + + "'><br><input type='hidden' value='" + top + "' name='top[" + + "]' id='top" + + "'>"; document.getelementbyid("frmmain").appendchild(newdiv); var top_button_left_pos = -75; var spanclick = document.getelementbyid('span' + i); spanclick.onclick = function (e) { alert("hello world"); }; $(function () { $("#div" + i).resizable({ autohide: true }); $("#div" + i).resizable({ }); $("#" + id).draggable({ }); }); } createtextbox('1', 'draggable', '15', '15', '300', '300', 'newtextarea','1','1','solid','#000000','3'); html
<form id="frmmain" name="frmmain" enctype="multipart/form-data" method="post"> <div id="content"></div> </form>
ok don't prevent default (that need select after all) , handle mouse down instead of click (i right, click fires late):
spanclick.onmousedown = function (e) { e.stoppropagation(); }; also reset cursor style inherits draggable div , go.
Comments
Post a Comment