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

jsOnly option for Tooltip.js #15360

Closed
wants to merge 1 commit into from
Closed

jsOnly option for Tooltip.js #15360

wants to merge 1 commit into from

Conversation

ricardopolo
Copy link

Fixes #15359
When using Tooltip.js it adds data-original-title and title to the DOM if they does not exist.

Calling

$(this).tooltip({ 'placement': 'bottom', 'title': 'Tooltip text'})

Gets a code like this

<span data-original-title="" title="">John</span>

After this PR you can call tooltip with an optional attribute for javascript only solutions (not using data html attributes).
Calling

$(this).tooltip({ 'placement': 'bottom', 'title': 'Tooltip text', jsOnly: true })

Now does not change the DOM

<span>John</span>

@twbs-savage
Copy link

Tests passed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: CONFIRMED

Commit: 37a3853
Build details: https://travis-ci.org/twbs-savage/bootstrap/builds/43976314

(Please note that this is a fully automated comment.)

@ricardopolo
Copy link
Author

@cvrebert what do you think about this solution? What should be do to get it merged?

@cvrebert
Copy link
Collaborator

Adding a configuration option like this seems unnecessary to me. I think we should simply tweak the logic slightly instead; no point in creating empty attributes in the first place, IMO.

@cvrebert cvrebert added the js label Dec 15, 2014
@melimanrique
Copy link

@cvrebert I've looking at this issue and I think a simple solution like this one could do what @ricardopolo wants and avoid creating an empty attribute.
In the jquery.tipsy.js file tweaking the logic with something like this:

Tooltip.prototype.fixTitle = function () {
    var $e = this.$element;
    if ($(this).attr('title') || typeof($(this).attr('data-original-title')) != 'string'){
        if($(this).attr('data-original-title')){
            $(this).attr('data-original-title', $(this).attr('title') || '').removeAttr('title');
        }
    }
}

What do you think?

@ricardopolo
Copy link
Author

@melissamanrique I do agree with your logic 👍

@ricardopolo
Copy link
Author

@cvrebert any opinion? Do you agree with @melissamanrique idea? Its important to me get this merged.

@ricardopolo
Copy link
Author

I'm closing this PR because looks like it will not be merge.

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

Successfully merging this pull request may close these issues.

How to avoid tooltips adding title & data-original-title attributes to DOM?
4 participants