Skip to content

Commit

Permalink
Add callback event
Browse files Browse the repository at this point in the history
  • Loading branch information
general03 committed May 30, 2016
1 parent 6057f16 commit 2ddda26
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 2 additions & 0 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
dynatab.ajaxType = 'GET';
dynatab.prefixIdTab = 'css';
dynatab.contentId = 'content-search-css';
dynatab.callback = function(){alert('Click done!')};
var idGenerated = Math.round(Math.random() * (9999 - 1) + 1);
dynatab.createTab(
'list__table1',
Expand All @@ -52,6 +53,7 @@
dynatab.ajaxType = 'GET';
dynatab.prefixIdTab = 'css';
dynatab.contentId = 'content-search-css';
dynatab.callback = function(){};
var idGenerated = Math.round(Math.random() * (9999 - 1) + 1);
dynatab.createTab(
'list__table2',
Expand Down
18 changes: 10 additions & 8 deletions dynatab.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/*!
* Dynamic tab management for foundation 5
*
* https://github.com/general03/dynatab.git
* http://github.com/general03
*
* @author RIGAUDIE David
* @version 0.0.1
* @version 0.1.0
*/

(function (global) {
Expand All @@ -18,6 +17,7 @@
dynatab.contentId = 'content';
dynatab.ajaxType = 'POST';
dynatab.prefixIdTab = '';
dynatab.callback = function(){};

/*
* Public methods
Expand All @@ -26,16 +26,16 @@
// Create Tab
dynatab.createTab = function (tabClass, contentClass, textContentTab, urlAjax, dataAjax) {
$.ajax(
{
{
url : urlAjax,
data: dataAjax,
type: dynatab.ajaxType
}).done(function( data ) {

$('.'+contentClass+' section').removeClass('active');
}).done(function( data ) {
$('.'+contentClass+' section').removeClass('active');

$('.'+contentClass).append(data);

// <input type="hidden" name="id-tab-section" />
var idTable = dynatab.prefixIdTab + '-' + dataAjax["id-tab-section"];

var liContent = $('<li class="tab-title active" role="presentational" >')
Expand Down Expand Up @@ -65,11 +65,13 @@
}
});

}).fail(function(e){console.log(e)});
dynatab.callback();
}).fail(function(e){console.log(e)});

};

// Export dynatab into global space
global.dynatab = dynatab;

}(window));

0 comments on commit 2ddda26

Please sign in to comment.