diff --git a/README.md b/README.md index a13fbd3..0096c4b 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ To use css3 animation effects please include [Animate.css](http://daneden.github | tooltipHover | false | Abillity to interact with the tooltip content | | content | null | The content of the tooltip, can be text, html or whatever you want | | ajaxContentUrl | null | Url for Ajax content | +| ajaxContentBuffer | 0 | Buffer timer for Ajax content | | contentElementId | null | Normally used for picking template scripts | | useTitle | false | To use the default title attribute as content (true, false) | | templateEngineFunc | null | A function that compiles and renders the content | diff --git a/demo/index.html b/demo/index.html index c826ff2..a710362 100644 --- a/demo/index.html +++ b/demo/index.html @@ -140,7 +140,8 @@ jQuery('.ajax').tipso({ background: 'tomato', useTitle: false, - ajaxContentUrl : 'ajax.html' + ajaxContentUrl : 'ajax.html', + ajaxContentBuffer : 5000 }); // Destroy Tipso jQuery('.destroy-tipso').on('click', function(e){ @@ -293,6 +294,7 @@

Defaults

tooltipHover : false, content : null, ajaxContentUrl : null, + ajaxContentBuffer : 0, contentElementId : null, useTitle : false, templateEngineFunc: null, @@ -739,7 +741,8 @@

Ajax content

jQuery('.ajax').tipso({ background: 'tomato', useTitle: false, - ajaxContentUrl : 'ajax.html' + ajaxContentUrl : 'ajax.html', + ajaxContentBuffer : 5000 }); diff --git a/src/tipso.js b/src/tipso.js index fe646f4..0ce6ba7 100644 --- a/src/tipso.js +++ b/src/tipso.js @@ -40,6 +40,7 @@ tooltipHover : false, content : null, ajaxContentUrl : null, + ajaxContentBuffer : 0, contentElementId : null, //Normally used for picking template scripts useTitle : false, //Use the title tag as tooptip or not templateEngineFunc: null, //A function that compiles and renders the content @@ -148,6 +149,10 @@ obj.hide(); }); } + if(obj.settings.ajaxContentUrl) + { + obj.ajaxContent = null; + } }, tooltip: function() { if (!this.tipso_bubble) { @@ -305,11 +310,28 @@ title = this._title; if (obj.settings.ajaxContentUrl) { - content = $.ajax({ - type: "GET", - url: obj.settings.ajaxContentUrl, - async: false - }).responseText; + if(obj._ajaxContent) + { + content = obj._ajaxContent; + } + else + { + obj._ajaxContent = content = $.ajax({ + type: "GET", + url: obj.settings.ajaxContentUrl, + async: false + }).responseText; + if(obj.settings.ajaxContentBuffer > 0) + { + setTimeout(function(){ + obj._ajaxContent = null; + }, obj.settings.ajaxContentBuffer); + } + else + { + obj._ajaxContent = null; + } + } } else if (obj.settings.contentElementId) {