Skip to content

Instantly share code, notes, and snippets.

@JMichaelVelasquez
Created February 8, 2017 12:46
Show Gist options
  • Save JMichaelVelasquez/97f19178530b64e3a93eeaa4cc9b8a25 to your computer and use it in GitHub Desktop.
Save JMichaelVelasquez/97f19178530b64e3a93eeaa4cc9b8a25 to your computer and use it in GitHub Desktop.
CSVSevice = (function ($) {
// logic here
var csvBtn = '.cta-download-csv';
var $csvBtn = $(csvBtn);
var data = {}
function addListeners() {
$('body').click('.cta-download-csv', function(event){
event.preventDefault();
console.log('clicked');
})
}
function setup() {
var _this = this;
console.log('_this', _this)
addListeners();
}
function setUpFakeData(){
data = {
"agent": "1",
"brand": "1",
"branch": "1",
"user": "1",
"service": null,
"startDate": "2017-01-01T00:00:00+0000",
"endDate": "2017-01-01T00:00:00+0000"
};
}
function callEndPoint(){
console.log($,'endpoint');
var request = $.ajax({
url: "downloads/csv",
method: "GET",
data: { id : 1 },
dataType: "html"
});
request.done(function( msg ) {
console.log('done', msg);
});
request.fail(function( jqXHR, textStatus ) {
console.log( "Request failed: " + textStatus );
});
}
return {
initialise: function (jQuery) {
// $ = jQuery;
//selector and listener to attach on the body for delegation.
// $csvBtn.each(setup);
// console.log('init');
},
fake: function () {
setUpFakeData();
callEndPoint();
}
};
})(jQuery);
// CSVSevice.initialise();
console.log('CSVSevice', jQuery('body'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment