Cannot reference methods on my JQuery prototype class
I'm defining the behaviour for my content_item elements like this:
$.fn.makeContentItem = function() {
$(this).selectItem = function() {
$(".content_item").removeClass("selected");
$(this).addClass("selected");
console.log($(this).css('width'));
}
$(this).click(function(event) {
console.log($(this));
$(this).selectItem();
});
}
I then apply makeContentItem with:
$(".content_item").makeContentItem();
Clicking a content_item element generates this error:
Uncaught TypeError: Object [object Object] has no method 'selectItem'
No comments:
Post a Comment