user1493920
user1493920

Reputation:

Using Html Tag in Jquery Ui Dialog

I'm Using Jquery Ui Dialog and have problem setting text. I'm using this code to insert a link:

$('#dialog').text(<a href=\"#\" >Click Here</a>).dialog();

But it shows the code and tags instead of the link. How can I use tags there?

Upvotes: 0

Views: 2280

Answers (4)

Javier Brooklyn
Javier Brooklyn

Reputation: 634

Check http://jqueryui.com/dialog/ The place where the text appears is:

<div id="dialog" title="Basic dialog">
<p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>

And in the documentation (http://api.jqueryui.com/dialog/) there is no .text as function

Upvotes: 0

alexpls
alexpls

Reputation: 1964

The issue here is that you're using the text function, which is just for text as it escapes characters needed for valid HTML.

You should instead be using the html function, with it your working code would be:

$('#dialog').html("<a href=\"\">Click Here</a>").dialog();

Upvotes: 0

Omid Kosari
Omid Kosari

Reputation: 287

when you use text , you exactly tell the jquery ui core to treat that string as a text. You can simply use HTML like this :

$('#dialog').html('<a href="#" >Click Here</a>').dialog();

Upvotes: 5

Shlomi Komemi
Shlomi Komemi

Reputation: 5545

try this:

$("<a href=\"#\" >Click Here</a>").appendTo('body').dialog();

Upvotes: 0

Related Questions