Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Showing tips on load, destroying on ajax request begin, and recreating
18th May, 18:51 (This post was last modified: 18th May 20:14 by tones411.)
Post: #1
Showing tips on load, destroying on ajax request begin, and recreating
I'm working in ASP.NET (2008)

What my site needs is to show tooltips when a user hits the page.

I found that when I left tooltips up jquery would get null object errors while the user is using other parts of the page, even when the parts of the page being used were not touching the tooltips target.

Where jquery was getting upset:
JS Code
var G=this[0].getBoundingClientRect()


The code I'm currently using to show on page load:

JS Code
function loadInlineHelp(){
 
   $('span.target.help').each(function () 
   { 
      // id of the target = the class of the content 
      var targetID = $(this).attr("id"); 
      // get the content 
      var contentTip = $('.' + targetID);
      if(contentTip.html())
      { 
           $('#' + targetID).qtip({        
                 content: {
                text: contentTip
             }, 
             style: { 
                width: 200,
                padding: 5,
                background: '#A2D959',
                color: 'black',
                textAlign: 'center',
                border: {
                    width: 7,
                    radius: 5,
                    color: '#A2D959'
                },
                tip: pointerPos,
                name: 'dark' // Inherit the rest of the attributes from the preset dark style
              }, 
             show: { ready: true }
          }); 
      }
    }); 
};


So I thought I would destroy the tips before each ajax call and recreate them after.

The code wiring the begin and end request:

JS Code
$(function () {
  Sys.Application.add_init(application_init);  
  function application_init() 
  {
      var pageRequestManager = Sys.WebForms.PageRequestManager.getInstance();
      pageRequestManager.add_beginRequest(
      function()
     { 
       //anything inside this function will be fired before the update panel calls the server
       inlineHelpTempClose()
      });
      pageRequestManager.add_endRequest(
      function()
      {
        //anything inside this function will be fired again when the update panels refresh
        loadInlineHelp();
      });
  }
});


Lastly the code that destroys the tips:

JS Code
function inlineHelpTempClose(){ 
   $('span.target.help').each(function () 
   { 
      // id of the target 
      var targetID = $(this).attr("id");  
      // hide target
      $('#' + targetID).qtip("destroy");     
   }); 
};


This approuch has failed also the inlineHelpTempClose() does get called on a ajax call but now qtip is throwing an error saying that the value is null at this point:

JS Code
return $(this).data('qtip').interfaces;


Any suggestions on a better approuch or whats going wrong?

Thank you.
Find all posts by this user
Quote this message in a reply
19th May, 14:09
Post: #2
Showing tips on load, destroying on ajax request begin, and recreating
I found my issue there was nothing wrong with the code, but where I implemented it in the cycle. I added the script in the footer of the page but there is currently many other scripts included in the page header. When I added it near the top of the header scripts it worked well.
Find all posts by this user
Quote this message in a reply
19th May, 19:16
Post: #3
Showing tips on load, destroying on ajax request begin, and recreating
Glad to hear you got it sorted mleduc. I literally only just noticed you're post as you replied to the problem, sorry about that.

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
  tip showing 2 times gkielwasser 8 240 5th May 19:00
Last Post: Craig
  [Solved] qtip showing content from db doesn't change when content in db changes. vtoepel 2 144 23rd April 16:02
Last Post: vtoepel
  [Solved] One Target Multiple Tool Tips rd42 1 267 19th February 18:24
Last Post: rd42
  [Solved] Multi tips not 100% times work dmhorse 1 272 9th January 18:19
Last Post: Craig
  [Solved] Browser still showing regular tooltip in addition to qTip Ryan Williams 2 848 18th December 19:54
Last Post: Craig
  [Solved] ajax data request on hover settoloki 0 482 30th November 08:42
Last Post: settoloki
  [Solved] [Solved] Hide all other tips runge 2 1,050 30th September 14:31
Last Post: knowlton
  [Solved] Dynamic content not showing? dabd 3 812 21st August 18:17
Last Post: Craig
  Qtip works but not always [stuck tooltip and sometimes not showing] bittyme 5 800 15th August 00:14
Last Post: bittyme
  [Solved] Qtip and Lazy Load Plugin [Solved] usman 3 1,026 9th August 17:31
Last Post: Craig



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