I have this code -
jQuery('.wymeditor').wymeditor( {
html: '<p>Hello, World!<\/p>',
postInit: function(wym) {
var html = "<li class='wym_tools_newbutton'>"
+ "<a name='NewButton' href='#'"
+ " style='background-image:"
+ " url(js/wymeditor/img/media.png);'"
+ " title='Insert an image' >"
+ "</a></li>";
jQuery(wym._box).find(wym._options.toolsSelector + wym._options.toolsListSelector).append(html);
jQuery(wym._box).find('li.wym_tools_newbutton a').click(function() {
jQuery('#modal').show().css( { 'left': (winW-980)/2+'px', 'top': '100px' } ).load('admin_list_media.php');
jQuery('.imgname').bind('change',function(){
alert('123');
var InsertImg = '#'+jQuery(this).attr('id');
wym.insert('<img src="uploads/'+jQuery(InsertImg).val()+'" />');
jQuery('#modal').empty().hide();
});
return(false);
} );
}
} );
which adds a new button to a wym editor. This opens a modal which contains images, the idea is to select an image and insert into the wym editor. Works if i use jQuery('.imgname').live('change',function(){ ...
but not if I use jQuery('.imgname').bind('change',function(){
problem is I have to use .bind() because the change event handler gets bound every time the modal opens and so I dupliacte image inserts each time I was told to replace .live() with .bind() but it doesn't work (OK in my code). Suggestions please
Solved it by moving the insert outside of the onchange section