paging mod, binding actions/callback per form within lesson

This commit is contained in:
Jason White 2016-09-22 23:41:02 -04:00
parent 1fff86fa2d
commit 95526b5100

View File

@ -22,18 +22,19 @@ define(['jquery',
$(window).scrollTop(0); //work-around til we get the scroll down sorted out $(window).scrollTop(0); //work-around til we get the scroll down sorted out
this.initPagination(); this.initPagination();
}, },
//TODO: reimplement this in custom fashion maybe?
makeFormsAjax: function () { makeFormsAjax: function () {
var options = { // will bind all forms with attack-form class
success:this.onAttackExecution.bind(this), var self = this;
url: this.model.urlRoot, $("form.attack-form").each(function(form) {
type:'GET' var options = {
// $.ajax options can be used here too, for example: success:self.onAttackExecution.bind(this),
//timeout: 3000 url: this.action,
}; type:this.method,
//hook forms //TODO: clarify form selectors later // additional options
$("form.attack-form").ajaxForm(options); };
$(this).ajaxForm(options);
});
}, },
initPagination: function() { initPagination: function() {
@ -56,7 +57,7 @@ define(['jquery',
// Besides, the new MVC code registers an event handler that will reload the lesson according to the route. // Besides, the new MVC code registers an event handler that will reload the lesson according to the route.
$('form').submit(function(event){ $('form').submit(function(event){
$.get(this.action, "json") $.get(this.action, "json")
.done(self.reLoadView.bind(self)) //.done(self.reLoadView.bind(self))
.fail(function() { alert("failed to GET " + url); }); .fail(function() { alert("failed to GET " + url); });
}); });
}, },
@ -111,11 +112,7 @@ define(['jquery',
showCurContentPage: function(isIncrement) { showCurContentPage: function(isIncrement) {
this.$contentPages.hide(); this.$contentPages.hide();
if (isIncrement) { this.$el.find(this.$contentPages[this.currentPage]).show();
this.$el.find(this.$contentPages[this.currentPage]).slideDown(300);
} else {
this.$el.find(this.$contentPages[this.currentPage]).slideUp(300);
}
}, },
hideNextPageButton: function() { hideNextPageButton: function() {