Skip to content

Allow adding html elements as tooltip content #983

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ docs
*.patch
.DS_Store
.settings
*.sw?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add this to your global gitignore via core.excludesfile. I actually didn't realize we had so many files in here, I'm going to rip these out :-P

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this.

26 changes: 26 additions & 0 deletions tests/unit/tooltip/tooltip_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,32 @@ test( "content: string", function() {
}).tooltip( "open" );
});

test( "content: element", function() {
expect( 1 );
var content = "<p>This is a <i>test</i> of the emergency broadcast system.</p>"
var element = $( content )[ 0 ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many var statements.

$( "#tooltipped1" ).tooltip({
content: element,
open: function( event, ui ) {
// Getting just the contents of the tooltip wrapper.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this comment.

equal( ui.tooltip[ 0 ].firstChild.innerHTML, content );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comparison looks questionable. Not sure about a better way to test this. Maybe domEqual can be used here. Also applies to the equal call below.

}
}).tooltip( "open" );
});

test( "content: jQuery", function() {
expect( 1 );
var content = "<p>This is a <i>test</i> of the emergency broadcast system.</p>"
var element = $( content );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too may var statements.

$( "#tooltipped1" ).tooltip({
content: element,
open: function( event, ui ) {
console.log( ui.tooltip );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this.

equal( ui.tooltip[ 0 ].firstChild.innerHTML, content );
}
}).tooltip( "open" );
});

test( "items", function() {
expect( 2 );
var event,
Expand Down
2 changes: 1 addition & 1 deletion ui/jquery.ui.tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ $.widget( "ui.tooltip", {
that = this,
eventType = event ? event.type : null;

if ( typeof contentOption === "string" ) {
if ( typeof contentOption === "string" || contentOption.nodeType || contentOption.jquery ) {
return this._open( event, target, contentOption );
}

Expand Down