Skip to content

Commit

Permalink
clean and remove promise on triggerHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
JavaTMP committed Nov 5, 2018
1 parent 7a72f45 commit 0b737f9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 34 deletions.
4 changes: 2 additions & 2 deletions dist/bootstrap-actionable.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 28 additions & 31 deletions js/bootstrap-actionable.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,39 +109,36 @@
var event = localOptions.linkEvent;
event.preventDefault();
var removeEvent = $.Event(localOptions.containerRemoveEventName, {_newTarget: $this});
$(localOptions.outputElement).triggerHandler(removeEvent).promise().done(function () {
if (!removeEvent.isDefaultPrevented()) {
$(localOptions.outputElement).off(localOptions.containerReadyEventName).promise().done(function () {
$(localOptions.outputElement).off(localOptions.containerRemoveEventName).promise().done(function () {
$(localOptions.outputElement).off(removeEvent).promise().done(function () {
$.ajax({
type: localOptions.ajaxMethodType,
async: true,
cache: localOptions.ajaxCache,
dataType: localOptions.ajaxDataType,
url: $this.attr("href"),
data: localOptions.ajaxDefaultData,
beforeSend: function (jqXHR, settings) {
if ($.isFunction(localOptions.ajaxBeforeSend)) {
return localOptions.ajaxBeforeSend.call(localOptions, jqXHR, settings);
}
},
success: function (response, textStatus, jqXHR) {
if ($.isFunction(localOptions.ajaxSuccess)) {
return localOptions.ajaxSuccess.call(localOptions, response, textStatus, jqXHR);
}
},
error: function (jqXHR, textStatus, errorThrown) {
if ($.isFunction(localOptions.ajaxError)) {
return localOptions.ajaxError.call(localOptions, jqXHR, textStatus, errorThrown);
}
}
});
});
var removeResponse = $(localOptions.outputElement).triggerHandler(removeEvent);
if (!removeEvent.isDefaultPrevented()) {
$(localOptions.outputElement).off(localOptions.containerReadyEventName).promise().done(function () {
$(localOptions.outputElement).off(localOptions.containerRemoveEventName).promise().done(function () {
$.ajax({
type: localOptions.ajaxMethodType,
async: true,
cache: localOptions.ajaxCache,
dataType: localOptions.ajaxDataType,
url: $this.attr("href"),
data: localOptions.ajaxDefaultData,
beforeSend: function (jqXHR, settings) {
if ($.isFunction(localOptions.ajaxBeforeSend)) {
return localOptions.ajaxBeforeSend.call(localOptions, jqXHR, settings);
}
},
success: function (response, textStatus, jqXHR) {
if ($.isFunction(localOptions.ajaxSuccess)) {
return localOptions.ajaxSuccess.call(localOptions, response, textStatus, jqXHR);
}
},
error: function (jqXHR, textStatus, errorThrown) {
if ($.isFunction(localOptions.ajaxError)) {
return localOptions.ajaxError.call(localOptions, jqXHR, textStatus, errorThrown);
}
}
});
});
}
});
});
}
};

BootstrapActionable.prototype.populateByLinkEvent = function (populateOptions) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootstrap-actionable",
"version": "1.0.10",
"version": "1.0.11",
"description": "Actionable plugin is a small Javascript code that help implement click actions for a and button tags by declarative way and provide functionalities to load AJAX content in Bootstrap Modal Wrapper instance.",
"keywords": [
"bootstrap",
Expand Down

0 comments on commit 0b737f9

Please sign in to comment.