我有這樣的代碼 -JQuery的.bind()格式正確
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);
});
}
});
它新增了一個按鈕,一個wym編輯器。這將打開一個包含圖像的模式,這個想法是選擇一個圖像並插入到wym編輯器中。如果我使用jQuery('.imgname').live('change',function(){ ...
,但是如果我使用jQuery('.imgname').bind('change',function(){
,則不適用問題是我必須使用.bind(),因爲每次打開模式時都會綁定更改事件處理程序,所以每次我被告知要替換.live()與.bind()但它不起作用(在我的代碼中確定)。建議請