darsain / tooltip

JavaScript Tooltip component.
http://darsa.in/tooltip
190 stars 15 forks source link

not working #21

Closed craigcosmo closed 8 years ago

craigcosmo commented 9 years ago
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" src="js/tool.js"></script>
<link rel="stylesheet" type="text/css" href="css/tooltip.css">

<script type="text/javascript">
    $(function(){
        var tip = new Tooltip('Foo bar!');
        tip.position(200, 200).show();
    });

</script>
</head>
<body>
<div class="tooltip"></div>

</body>
</html>

the error is body is null

darsain commented 9 years ago

I can't make anything out of this. Replicate the issue on jsfiddle or a similar service.

jenschr commented 8 years ago

@darsain I think what he meant (without replying you your question) is that when running it like above, it'll crash. The Component package manager is no longer maintained, so he (and I) installed it "manually" by just including the files.

In "tooltip.js" you have several references to things like body.appendChild(this.element). At that point in time, "body" is null. By changing it to document.body.appendChild(this.element) it worked for me, but I presume that's also not how it's meant to be used?

PS: thanks for building this!

ghost commented 6 years ago

ty @jenschr yep, i don't use require, so i replaced those, now it works great! here is the updated one if anyone needs