JSFiddle - React, Tailwind, and code Playground
JavaScript
// DI with Requirejs.
define([
'jquery',
'CreateArticleVisitor',
'MouseLoadingHelper'
], function($, CreateArticleVisitor){
// Private object and function.
var Gateway = {};
Gateway.put = function(url, data, callback) {
// Ajax call to get xml.
$.ajax({
type: "POST",
dataType: "xml",
url: url,
data: data,
//context:context,
async: true,
beforeSend: function() {
// Remove any previous elements.
$(".Ba-slideresponder[data-popup-type='responder']").remove();
// Remove any previous error and the popup processing
$("label",data.form).removeClass('error');
},
success: function (returndata,textStatus, jqXHR) {
// Send the response to callback.
callback(returndata);
}
});
};
// Define the object constructor.
var Plugin = function() {
};
// Define the public api and its public methods by extending the object.
Plugin.prototype = {
defaults : {
button: {},
onSuccess: function() {}
},
arrival : null,
put : function(options, callback) {
// Remember the root as $root.
var $root = this;
// Mix in the passed in options with the default options
var settings = $.extend({},$root.defaults,options);
// To be safe, unbind any previous click event before binding the new one.
settings.button.unbind("click").click(function(e){
// Create a loading tip from the loading plugin.
var loader = $(document.body).mouseLoader('create',{
event: e
});
// Set the object.
...