Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get different timestamp and global var?
2nd June, 14:36
Post: #1
How to get different timestamp and global var?
Hi , great qTip:
Question_1: I wrote following scripts , want to load dynamic content by another PHP script, bug IE cached this "GET" request . So I append a TIMESTAMP into the GET string, but it is not work - the time stamp is same totally each times when clicked the id#tooltip_gzlb.
Question_2: I want to get a global var named "selected" when qTip show , but it is always 0 (should be 0 or 1 or 2 ... )
Sorry for my poor english grammar, I wish you can understand. Thanks ! [Atan]
--------------------------
var selected ;//which tab has been selected , some func change this it!
... ...
function click_show()
{
$('[tooltip_gzlb]').each(function() // Select all elements with the "tooltip" attribute
{
$(this).qtip({ style: {width: { min:300 ,max:640 }, padding: '14px', border: { width: 9, radius: 9, color: '#666666'}, name: 'light' , tip: 'bottomLeft'},
content: {url: 'show_select.php' ,
data: { id: $(this).attr('tooltip_gzlb') , tab: selected , timestamp: new Date().getTime() },
method: 'get' ,
title: {text: '<font size=2>Select Type</font>', button: '×'}},
position: {target:'mouse' , corner: { target: 'topRight', tooltip: 'bottomLeft' }, adjust: {mouse : false , screen : true}},

show: { solo: false , when: { event: 'click' } },
hide: { when: { event: 'click' } }
}); // Retrieve the tooltip attribute value from the current element
});
}
Find all posts by this user
Quote this message in a reply
2nd June, 18:07
Post: #2
How to get different timestamp and global var?
ad209,

The problem you're facing is related to how the script is parsed. When your assigning the value of 'selected' when creating the tooltips, it's always going to be zero because its value is passed at document load. If you want to pass a different timestamp or data each time, you'll have to use the onRender functionality instead like so:

JS Code
var selected;
 
function click_show()
{
    $('[tooltip_gzlb]').each(function() // Select all elements with the "tooltip" attribute
    {
      $(this).qtip(
      {
         content: {
            text: false,
            title: { text: '<font size=2>Select Type</font>', button: '×'} 
         },
         position: { target:'mouse', corner: { target: 'topRight', tooltip: 'bottomLeft' }, adjust: { mouse : false , screen : true } },
         show: { solo: false  , when: { event: 'click' } },
         hide: { when: { event: 'click' } },
         style: { width: { min:300, max:640 }, padding: '14px', border: { width: 9, radius: 9, color: '#666666'}, name: 'light' , tip: 'bottomLeft' },
         api: {
            onRender: function()
            {
               var url, data, method, timestamp;
 
               // Setup timestamp
               timestamp = new Date().getTime();
 
               // Setup properties
               url = 'show_select.php';
               data = { 
                  id: this.elements.target.attr('tooltip_gzlb'), 
                  tab: selected, 
                  timestamp: timestamp
               };
               method = 'GET';
 
               // Load the content
               this.loadContent(url, data, method);
            }
         }
      });
   });
}

Craig Thompson
Web Developer / Designer
Craigsworks
http://www.craigsworks.com
Visit this user's website Find all posts by this user
Quote this message in a reply
3rd June, 13:56
Post: #3
How to get different timestamp and global var?
Thank you very much , It worked well in my HTML Page!
But it has a little problem:
I insert a "alert(timestamp);" sentence after "timestamp = new Date().getTime();" ,
First time I clicked one of the element [tooltip_gzlb] , the alert dialog popup and give a timestamp.
But when I close that qTip(click the 'x') , and click the element [tooltip_gzlb] same one again , the alert dialog can not be popup.
I think , because when I click it at the first time the qTip object has been created maybe? but why when I click again the script can not be run?
Find all posts by this user
Quote this message in a reply
4th June, 13:47
Post: #4
How to get different timestamp and global var?
ad209,

onRender is only called once when the tooltip is rendered. If you want a callback which fires every time the tooltip is shown use the onShow callback instead.

Craig Thompson
Web Developer / Designer
Craigsworks
http://www.craigsworks.com
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  [Solved] tip position when using global styles xenolith5 2 1,026 3rd February 09:17
Last Post: xenolith5
  Global enabling/disabling on ajax sdelmastro 1 390 2nd August 12:07
Last Post: Craig
  Render the tooltip after a predefined timestamp masudiiuc 1 421 5th June 21:20
Last Post: Craig
  Need Global Close/Hide gigbuilder 1 561 23rd November 00:30
Last Post: Craig
  Global qtip elements with different content camslaz 5 1,434 6th November 22:45
Last Post: pashcan
  create new global show and hide gtraxx 0 460 21st October 13:30
Last Post: gtraxx



User(s) browsing this thread: 1 Guest(s)