enyo / opentip

Opentip is an open source javascript tooltip based on the protoype framework.
http://www.opentip.org
1.25k stars 401 forks source link

Error: Multiple elements provided. #107

Closed hegdeashwin closed 10 years ago

hegdeashwin commented 10 years ago

Hi

My HTML Template code:

<span class="tooltip">Open Tip 1</span>

As above span is dynamically generated. Thus, It will be multiple as below:

<span class="tooltip">Open Tip 1</span>
<span class="tooltip">Open Tip 2</span>

my JS code:

Opentip.styles.factPopupStyle = {
        extends: "alert",
    stem: true,
    background: '#e48895',
    borderColor: '#e48895',
    borderRadius: 0
};
myTip = new Opentip($('.tooltip'), "Hello World", { style: "factPopupStyle" });

When i executed the code it showing me below error:

Error: Multiple elements provided.

I am not able to figure out that is the issue?

enyo commented 10 years ago

If you create a tooltip with new Opentip you need to provide only one element. Use the jquery adapter ($('.tooltip').opentip([...]);) to do what you want, or iterate over all tooltip divs and call new Opentip multiple times.