Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
qtip on element called with Ajax
30th August, 08:36 (This post was last modified: 30th August 08:38 by sisilone.)
Post: #1
qtip on element called with Ajax
Hello,
I've a class of elements to which I want to attach qtip. Well this works for static elements, but obviously not on the elements, of the same class, called through Ajax.
Is it possible to attach qtip also to the element called with ajax, like a method .live(), without add code for each script called async?

Share information about cities on KooKooZa!
Find all posts by this user
Quote this message in a reply
1st September, 18:12
Post: #2
RE: qtip on element called with Ajax
I'm assuming you are using an ajax function like $.ajax or $.post or $(id).load??

All you have to do is reattach the qtip to your elements in the success callback with jQuery's each function.

JS Code
$.ajax({
	type: "POST",
	url: "page.php",
	data: "yourdata=something",
	success: function(response){
 
		('.your_qTip_elements').each(function(){
      		$(this).qtip({
         		show: 'mouseover',
         		hide: 'mouseout',
                ...your qtip options
      		});
       });
 
	}
});



I hope this helps Smile
Find all posts by this user
Quote this message in a reply
2nd September, 08:11
Post: #3
RE: qtip on element called with Ajax
thank you for your answer, but it's a bad thing...I've to attach this function for every async request...

As I said I use tooltip for a specific class of elements and I create them calling a php function, I can write in this function the qtip code to attach the tooltip. I'll have n identical script for n elements of that class...it's not an elegant way...Sad

Share information about cities on KooKooZa!
Find all posts by this user
Quote this message in a reply
2nd September, 12:31
Post: #4
RE: qtip on element called with Ajax
sisilone, if you're planning on using qTip with the .live() methods I'd definitely suggest you take a look at porting your code over to the 2.0 releases. 1.x releases are quite resource heavy and can slow down your page quite bit if you have lots of them bound.

If you do move over to 2.0, you can use this as a starting point:

JS Code
// .delegate requires jQuery 1.4.2 and up. Use t he same event here as your tooltip show event
$('.selector').delegate('.selector', 'mouseover', function(event) {
   $(this).qtip({
      content: {
         ajax: {
            url: 'blah',
            data: {}
         }
      },
      show: {
         ready: true // Need this to make it show on first mouseover 
      }
   });
});


You can grab 2.0 here: http://github.com/craga89/qtip and the documentation here: http://craigsworks.com/projects/qtip_new/docs/

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
  Qtip data not find when using ajax pagereload reinier1991 1 88 10th May 07:52
Last Post: reinier1991
  [Solved] Dynamic Content From Page Element frogg3862 2 96 3rd May 17:12
Last Post: frogg3862
  [Solved] Pausing Vimeo on tooltips called with AJAX? daver_cl 4 392 14th March 20:39
Last Post: Craig
  [Solved] qTip Ajax data for text in a div akhil_csit 1 325 14th March 19:27
Last Post: Craig
  calling .html using the element id matthearn 0 311 24th February 15:08
Last Post: matthearn
  [Solved] Attach QTIP to any element with attribute "tooltip" slhilbert 7 412 15th February 14:44
Last Post: slhilbert
  [Solved] creating a qtip with ajax contents based on computed uri params punk.kish 1 419 25th January 15:50
Last Post: Craig
  [Solved] How to append QTip to some other element instead of document body prateekbansal 2 508 11th January 07:01
Last Post: prateekbansal
  [Solved] QTip content from existing div element on page? dcash 4 2,531 8th December 18:29
Last Post: Craig
  nested lists and qtip for the last mouseenter element ??? thbenda 0 341 4th October 09:24
Last Post: thbenda



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