Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Tipped.delegate and showOn:'click' problematic

edited January 2016 in Tipped
I am using Tipped.delegate to pick up on new tipped instances and find it excellent, but an issue I am coming across currently is that for some reason showOn:'click' appears to be ignored initially. For example, if I use Tipped.delegate('.tipped') and add the following simple markup to my DOM:
<div class="tipped" data-tipped-options="showOn:'click',inline:'inline_id_here'">I show on click!</div>

<div id="inline_id_here">
Hello World
</div>
If I mouse over the first element (the target), it will display immediately and ignore the showOn, but then showOn will kick in once that Tipped instance is closed and the item will then only show when clicked. Is there a reason for this? Or should .delegate not be used for entities with data-tipped-options specified?

Comments

  • edited January 2016
    The only option that'll conflict with delegate() is showOn on data-tipped-options, you can use all other options safely on data-tipped-options. I should probably make a note about that in the docs.

    Tipped.delegate() binds the showOn event to the body element at the moment it's called. So it only listens for a single event which might bubble up from other elements. Without any options given this event defaults to 'mouseenter'. Once a tooltip is initialized through a delegated event it'll start behaving like a regular tooltip and take into account options set on data-tipped-options, from there it no longer triggers based on the delegated event. This is why setting a different showOn event on data-tipped-options causes the behavior you describe.

    In order to work as you expected Tipped wouldn't be able to delegate based on a single event, because different tooltips might have different showOn events in their data-tipped-options attribute, defeating the purpose of delegation.
  • This makes sense, although I think it is probably avoidable if Tipped.delegate was reworked a little bit because Tipped.delegate is a little bit misleading, particularly when you see all data-tipped-options overrides being picked up, except for showOn. Thanks for your help with this. Really appreciated
Sign In or Register to comment.