javascript - User selection removed when opening a jQuery UI dialog box..how to fix this? -


i trying create link with:

document.execcommand('createlink',false,linkval); 

for getting link href value user using jquery ui dialog.

so when user select text on page & click on link open jquery ui dialog (this dialog contain form inside it).

$("a#link-it").on('click',function(e){     e.preventdefault();     $( "#dialog-form" ).dialog( "open" );    }); 

ui dialong inilization code looks this:

$( "#dialog-form" ).dialog({       autoopen: false,       height: 300,       width: 350,       modal: true,       buttons: {         "create": function() {         var linkval=$("#link").val();         document.execcommand('createlink',false,linkval);         $( ).dialog( "close" );         },         cancel: function() {           $( ).dialog( "close" );         }       },       close: function() {         allfields.val( "" ).removeclass( "ui-state-error" );       }     }); 

jquery ui dialog opening & working issue when user click on link open user selection got wiped immediatly browser window. command not working.

document.execcommand('createlink',false,linkval);  

so please suggest how can prevent wiping of user selection after opening ui dialog?

or if can suggest how wysiwyg editor link creating works?

finally solved using solution given here

take on https://code.google.com/p/rangy/

and

http://rangy.googlecode.com/svn/trunk/demos/saverestore.html


Comments

Popular posts from this blog

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

Android Gson.fromJson error -