0
我遇到了點擊事件不能使用Javascript MVC控制器的問題。Javascript MVC控制器和點擊事件
TEST.Assignments.AssignmentsController = function (element) {
var elements = {
activeAssignmentsPanel: $('#lpn-activeAssignments_Cont'),
assignmentViewLink: $("#lpn-activeAssignments_Cont table tr th a")
};
var _this = this;
var model = new TEST.Assignments.AssignmentModel();
this.buildAssignmentsList = function() {
var assignments = model.getActiveAssignmentsList({
assignmentMode: "active",
mock: true,
success: function (data) {
dust.render("ActiveAssignmentsPanel", data, function(err, out) {
elements.activeAssignmentsPanel.append(out);
});
}
});
};
this.getAssignmentDetails = function(assignmentId) {
console.log(assignmentId);
};
//bind all events
elements.assignmentViewLink.click(function (e) {
console.log("blah");
console.log($(this).data("assignmentKey"));
});
};//end assignments controller
$(function() {
var assignmentsController = new TEST.Assignments.AssignmentsController();
assignmentsController.buildAssignmentsList();
});
如果你看看//bind events
,我有一個應該工作的點擊功能。但事實並非如此。正在調用構造函數並正確地追蹤元素。任何想法爲什麼點擊事件不起作用?
嘗試過,仍然沒有運氣。元素在到達click事件之前已定義。我甚至嘗試過一個'實時'點擊事件,但這也不起作用。 – pfunc