У меня есть этот код:Динамическое назначение функции onclick с динамическими параметрами в JavaScript?
document.getElementById('img'+i).onclick = function(){popup_show('popup',array_msg[i]+'|||'+date('Y-m-d',strtotime(lec_date))+'-==-'+str_view_forConflict, 'AddEditSchedule;;popup_drag2;;EditSched;;'+String(array_msg_id[3])+';;view', 'popup_drag', 'popup_exit', 'screen-center', 0, 0);};
... но когда я нажимаю на изображении, данные array_msg[i]
являются последними данными цикла, то есть индекс длина цикла. Для этого я использую IE.
Пожалуйста, дайте мне представление о том, как это сделать. В FF он отлично работает, потому что я использую setAttribute
.
@bobince
document.getElementById('img'+i).onclick= popup_show.bind(window, 'popup',array_msg[i]+'|||'+date('Y-m-d',strtotime(lec_date))+'-==-'+str_view_forConflict,'AddEditSchedule;;popup_drag2;;EditSched;;'+array_msg_id[3]+';;view','popup_drag', 'popup_exit', 'screen-center', 0, 0 );
if (!('bind' in Function.prototype)) {
Function.prototype.bind= function(owner) {
var that= this;
var args= Array.prototype.slice.call(arguments, 1);
return function() {
return that.apply(owner,
args.length===0? arguments : arguments.length===0? args :
args.concat(Array.prototype.slice.call(arguments, 0))
);
};
};
}
есть ошибка: «tmp не определен» – Treby
Упс, исправлено. –
у вас есть .. голосуйте за мой вопрос .. спасибо .. – Treby