javascript - Preserve text selection in contenteditable while interacting with jQuery UI Dialog and text input -
i have jquery dialog making links in contenteditable span. problem clicking button open dialog causes selection lost, text input inside dialog causes selection lost. i can fix button -moz-user-select:none; -webkit-user-select:none doesn't work in chrome. i can fix input wrapping in iframe, that's messy , clicking anywhere else kills selection, example, dragging dialog around. i've seen solution @ how preserve text selection when opening jquery dialog , doesn't work in many browsers in contenteditable element, real inputs. is there nice solution problem? you save , restore selection using simple functions such following when dialog opened , closed. not familiar enough jquery dialogs know mechanism hooking dialog opening , closing. first, saveselection , returns range or textrange object should store in variable later pass restoreselection : function saveselection() { if (window.getselection) { sel = window.getselection(); if (...