开发者

JQuery get an image url with execCommand('InsertImage',true);

having some trouble with this - for some reason - prob. just me NE how what I need to do for a very basic RTE is grab an image url from some form of popup preferably a modal with an input field for the url that then uses execCommand('InsertImage'); to put the image into an editable div - the RTE is using an editable div in an iframe not a textarea.

If not clear this is the "route"

  1. click on "image" button in the RTE menu
  2. This opens a modal (JQuery)
  3. The modal is populated with thumbnails
  4. User clicks on thumbnail Click sets the value of a hidden input field (JQuery)
  5. User clicks a submit button (on the modal) that then triggers the execCommand('InsertImage') command.

so I guess my code would be something like: (pre wrapped with doc.ready etc.)

$('#getimagemodal').live('click',function(){
$('#imagemodal').fadeIn('slow').load('imagethumbs.php', function(){
$('.imageclass').live('click',function(){
$('#imageinput').val($(this).attr('src')); 
$('#setimage').live('click',function(){ 
document.getElementById("fraRTE").contentWindow.document.execCommand('InsertImage',true,$('#imageinput').val(); ) 
});  
}); 
})开发者_开发知识库;
}

But I am not sure and I cannot get the image src to transfer. Suggestions please Thanks in

Oh - it is being done this way as a user has a pre-existing image library not on the main server so imagethumbs.php will load the image thumbs via the library API. I ned the "clck action" rather than just a "insert src" type prompt.


OK got it to work like this:

$('#getimagemodal').live('click',function(){
    $('#imagemodal').fadeIn('slow').load('../admin/imagethumbs.php', function(){
        $('.imageclass').live('click',function(){
        $('#imageinput').val($(this).attr('src')); 
            $('#setimage').live('click',function(){ 
                var img = $('#imageinput').val(); 
                $('#imageinput').val(); 
                addImage(img);
                $('#imagemodal').fadeOut('slow').empty();
            return false;
            });
        });  
    }); 
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜