3

So I've got this popover which is working good, here is the html of the popover:

<div class="popover2"  onmouseover="$(this).mouseleave(function() {$(this).hide(); });">
    <div class="arrow"></div>
    <div class="popover2-inner">
        <span class="popover2-title">Popover() 2</span>
    <div class="popover2-content">
        <ul class="unstyled">
            <li><span>$200 Bronze</span><p>2 hrs. drivers training</p </li>
        </ul>
    </div>
</div>

And I've got this instantiation code:

    $('.popover2-test').popover({
    placement:'bottom',
    template: $('.popover2'),
    trigger: 'manual',
    animate: false,
    html: true,

        }).click(function(e) {
            e.preventDefault() ;
        }).mouseenter(function(e) {
            $(this).popover('show');
    });

But I want to move the inline onmouseover javascript stuff into the instantiation code. I don't know how to do this. Any help is great, thanks.

2
  • Give the tag an id and then just bind the event in JS. Unless that is the only tag with that class, in which case you can simply use the class. Commented Jul 3, 2012 at 21:44
  • Your going to have to be more specific, I don't know what your talking about, sorry and thanks! Commented Jul 3, 2012 at 21:45

3 Answers 3

4

Have you tried placing this line of code just after the instantiation code?

$('.popover2').mouseleave(function() { $(this).hide(); });
Sign up to request clarification or add additional context in comments.

Comments

2

just remove the inline and add:

$('.popover2').mouseleave(function(){
    $(this).hide();
});

Comments

2

There's no point only binding the mouseleave event onmouseover, since a mouseover event must fire before mouseleave anyway (AFAIK). So this would do:

$('.popover2').mouseleave(function() {
    $(this).hide();
});

This assumes, of course, that .popover2 exists when your 'instantiation code' runs.

If not,

$('.popover2').live('mouseleave', function() {
    $(this).hide();
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.