views:

36

answers:

3

I have qTip being called on items within a table..

$('#orders_table a[rel]').each(function (){
            $(this).click(function(){
                return false;
            }); 
            $(this).qtip({
                content: {
                    // Set the text to an image HTML string with the correct src URL to the loading image you want to use
                    text: 'Loading...',
                    url: $(this).attr('rel'),
                    // Use the rel attribute of each element for the url to load
                    title: {
                        text: 'Order Number ' + $(this).text(),
                        // Give the tooltip a title using each elements text
                        button: 'Close' // Show a close link in the title
                    }
                },
                position: {
                    corner: {
                        target: 'bottomMiddle',
                        // Position the tooltip above the link
                        tooltip: 'topMiddle'
                    },
                    adjust: {
                        screen: true // Keep the tooltip on-screen at all times
                    }
                },
                show: {
                    when: 'click',
                    solo: true // Only show one tooltip at a time
                },
                hide: 'unfocus',
                style: {
                    tip: true,
                    // Apply a speech bubble tip to the tooltip at the designated tooltip corner
                    border: {
                        width: 0,
                        radius: 4
                    },
                    name: 'light',
                    // Use the default light style
                    width: 570 // Set the tooltip width
                }
            })
        });

I then have the following callback function:

$('#orders_table a[rel]').each(function (){

            $(this).qtip({
            api: {
                onContentLoad:function() {
                        $('#select').change(function(){

                                alert('test');
                        });    
                }
            }                         
            })
        });

The qTip is loading dynamic content. That dynamic content has a select box with the id 'select'.

For some reason though, it doesn't seem to be calling the function AFTER the qTip has loaded the dynamic content.

Any ideas? I've tried onRender and onContentUpdate, which don't seem to be appropriate.

Thank you!

A: 

I'm not 100% sure if this is the same problem we had but when you set the anchor for the qTip to an ajax link, and that ajax link triggers a re-render of itself, qTip ends up getting un-rooted in DOM and callbacks and timers just stop working.

We solved this by anchoring qTip to a near-by element instead. Hope that helps.

BjornS
So I'm attaching qTip to a set of anchor's that have ref in them. You attach it to a different element? How will that work?
dave
We had to write some code that produced something similar to this; <a href="#" onClick="triggerTooltip(otherElementToBindTo); ajaxMagicHere();">a link!</a> we used this for instance to show when a user had put an element in the shopping basket, the triggerTooltip method would simply create a tooltip on the passed element (a near by span I believe) and then we used positioning and corner settings to make it appear like it was attached to the shopping cart icon. Its not the ideal solution but its the only one we found that works with ajax I'm afraid.
BjornS
A: 

The problem isn't the callback running, it's loading content with a specific ID. IDs are meant to be unique within a page, so instead use a class here, so that when more than one qTip loads, it won't invalidate the unique ID rule (causing #select to return the first of these elements, no all of them).

You can do that by changing your select to have a class (or not if it's the only <select> in the content), like this:

<select class="mySelect">

Then when binding, search for that element in the callback, like this:

$('#orders_table a[rel]').each(function (){
  $(this).qtip({
    api: {
      onContentLoad:function() {
        this.elements.content.find('select.mySelect').change(function() {
          alert('test');
        });    
      }
    }                         
  });
});

Also if you don't need the .each() loop for another reason, you can shorten it down to:

$('#orders_table a[rel]').qtip({
  api: {
    onContentLoad:function() {
      this.elements.content.find('select.mySelect').change(function() {
        alert('test');
      });    
    }
  }
});
Nick Craver
This doesn't seem to work... The ID's should be fine, because it's only one qTip loaded at a time so it's unique basically. However, I changed it to a class, tried both methods.. no luck!
dave
+1  A: 

Actually It needs a specific means different ID for different Control. So Try with different ID means pass some argument and make the Id different when You are creating the control dynamically.

It may solve you problem.

Umakanta.Swain