javascript - ckeditor insertHtml() form jquery.load -


<script type="text/javascript"> $( "#x_img" ).load( "../x_img.php?id=123" );   $("#x_img").delegate("img", "click",function() {        ckeditor.instances.editor1.inserthtml('<img src="'+$(this).attr('alt')+'" />'); }); </script> 

i have function loads images (x_img) user use. x_img jq.load in page.

using code click image insert, works ok. but, cannot image src value!

ckeditor shows this: <img src="undefined" />

is problem image on page?

if editor showing

<img src="undefined" />

then

$(this).attr('alt') 

will return undefined because img node doesn't have alt='something' attribute. undefined being concated img's src attribute.

try changing image tag following:

<img alt="/images/funtimesatthebeach.jpg" /> 

then, code should load image @ /images/funtimesatthebeach.jpg.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -