1
그래서 PHP 파일에 AJAX 게시물을 게시 할 예정인 작은 자바 스크립트 클래스를 만들었습니다. 클래스는 다음TypeError : this.functionName이 함수가 아닙니다.
var cms = cms || {};
cms.load_view = (function() {
return {
change: function() {
jQuery("#layout-switch a").on('click', function()
{
jQuery('#layout-switch a').removeClass('current');
jQuery(this).addClass('current');
var column_number = jQuery(this).attr('data-name');
var category = jQuery("#cat_id").val();
var data = {mode: column_number, cid: category};
this.postChange(data);
});
},
postChange: function(data) {
jQuery.ajax({
type: 'post',
url: SITEURL + "/modules/digishop/loadcategory.php",
data: data,
beforeSend: function() {
jQuery('#digishop').animate({
opacity: 0
}, 250, function() {
jQuery(this).addClass(column_number);
jQuery(this).animate({
opacity: 1
}, 250);
});
},
success: function (html) {
jQuery("#digishop").html(html);
}
});
return true;
}
}
})(jQuery);
jQuery(document).ready(function() {
cms.load_view.change();
});
그러나, 나는 this.postChange(data);
모든 아이디어는 일명, 방화범이 postChange
그것이 첫 번째 방법으로 호출되는 함수 아니라고 말한다 선택기를 클릭하면?
감사합니다.
'click' 이벤트 핸들러 내에서, 'this'는 핸들러가 바인딩 된 엘리먼트를 가리키며,이 경우 클릭 된'# layout-switch a' 엘리먼트입니다. 'jQuery (this) .attr ('data-name')'을하고 있기 때문에 당신이 알고있는 것 같습니다. –