Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onmouseover #10

Closed
marcojalongo opened this issue Apr 14, 2015 · 12 comments
Closed

onmouseover #10

marcojalongo opened this issue Apr 14, 2015 · 12 comments

Comments

@marcojalongo
Copy link

Hello, this is my code:

$(document).ready(function(){
    $("div.ajax" ).on( "mouseover", function() {
        $(this).tipso({
            background: null,
            useTitle: false,
            ajaxContentUrl : 'myfile.php?var='+$(this).data("id")
        });
    });
}); 

it works but why the tooltip is showed only the second time the mouse is over the div element (with class = ajax)?
Sorry, I'm newbe with jquery...

Thank a lot

@object505
Copy link
Owner

Hello,
You don't need the mouseover event, because tipso is already doing that.
So you just need to do this:

$(document).ready(function(){        
    $("div.ajax").tipso({
        background: null,
        useTitle: false,
        ajaxContentUrl : 'myfile.php?var='+$(this).data("id")
    });        
}); 

@marcojalongo
Copy link
Author

Ok, but the problem is that I have a lot of div with class = ajax;
how I can't retrieve $this data of specific div...?

@marcojalongo
Copy link
Author

I mean that your code give me var= undefined....

@object505
Copy link
Owner

Oh, I see.
Maybe something like this would help

var dataID;
$('div.ajax').on({
  mouseenter: function () {
    dataID = $(this).data('id');
  }
});
$("div.ajax").tipso({
    background: null,
    useTitle: false,
    ajaxContentUrl : 'myfile.php?var='+dataID 
});    

I guess in a future release of the plugin I would have to implement this.
Let me know if this works for you :)

@marcojalongo
Copy link
Author

it doesn't work... in console log i see "var=undefined" yet

Have you other suggestion?

thanks again...

@object505
Copy link
Owner

Well this works http://jsfiddle.net/1kb064w7/
Another thing is to give me the site url and let me check what is going on :)

@marcojalongo
Copy link
Author

It's work, but how to apply this example to "ajaxContentUrl" (not static "content") I'm using....? I tried to return from function the url of script (e.g.; return 'myscript.php?var='+dataID') but it doesn't work...

@marcojalongo
Copy link
Author

sorry... my application is on local server but use exactly same syntax...

@object505
Copy link
Owner

The same code will be used as here #10 (comment)

Basically that is the same code as in the jsfiddle. If you can make some test environment somewhere I can help you more :)

@marcojalongo
Copy link
Author

Ok; I've make following test environment:

  1. http://www.giglione.it/appl/mainscript.php

this is your solution (#10 comment); as you can see, ajax request send back "undefined" instead of values "var1", "var2",.... (in console log, too)

  1. http://www.giglione.it/appl/mainscript1.php

this is my "dirty" solution; it is ok, but only on second mouse over.

the ajax script for dynamic tip content (myscript.php) actually simply is:

@object505
Copy link
Owner

Based on your test environment I've tested this code and it is working.

    jQuery(document).ready(function(){          
        var dataID;
        jQuery('div.ajax').on({
            mouseenter: function () {
                dataID = $(this).data('id');            
            }
        });
        jQuery("div.ajax").tipso({
            useTitle: false,
            ajaxContentUrl: 'myscript.php?var='+dataID,
            onBeforeShow: function(){
                $('div.ajax').tipso('update', 'ajaxContentUrl', 'myscript.php?var='+dataID);
            }
        });              
    });

Let me know if it's works for you :)

PS: On your "dirty" version it works from the second hover because on the first you are calling the plugin for the first time and also you are calling the plugin for each element individually, not using the class .ajax but the element itself ( using "this" ).

@marcojalongo
Copy link
Author

Great!
thanks a lot!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants