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

Using HTML in select options ?? #594

Open
andyl opened this issue May 26, 2014 · 3 comments
Open

Using HTML in select options ?? #594

andyl opened this issue May 26, 2014 · 3 comments

Comments

@andyl
Copy link

andyl commented May 26, 2014

I'd like to display HTML tags in my select options. For example:
data-source='[{value:1,text:" Edit"},{value:2,text:"Example"}]'

By setting escape=false, I can get the text label to display HTML nicely. BUT the options in the pull-down menu are always rendered as text.

How can I make the pull-down menu options display HTML tags??

@acrawly
Copy link

acrawly commented May 27, 2014

There are two ways (that I can think of) to go about this:

  1. Cruise the source code and find where it builds the result set and ensure it's using a function that doesn't escape HTML. ie. JQuery.html() instead of JQuery.text()
  2. Use your CSS skills to simply style the result set how you want it to look.

From your question though, maybe your wanting to do the reserve and display the HTML on the page, not rendered and it currently is rendering it?

@HunterJoe
Copy link

I am trying to do something similar, but I don't want html tags to be rendered in the select options at all. I want text in the select options, so the users can choose a yes or no value. if yesm then I don;t want the text "YES" to be rendered as the output to the page, rather I want html to be rendered to the page.

It seems that this plugin overwrites the text value of the anchor tag that is the target object. How do I stop that from happening. see this fiddle for an example: http://jsfiddle.net/HunterJoe/smu1v3q0/1/

@HunterJoe
Copy link

Just figured it out. Changed line 3135 - 3137 from this:

 if(items.length) {
     text = items[0].text;
 }

to this:

 if(items.length) {
     text = items[0].output;
 }

then modified the object like so:

$('.dspPageEditable, .dspNavEditable').editable({
    value: "YES",
    source: [
        {value: "YES", text: 'YES', output:'<span class="icon fa fa-eye text-blue2"></span>'},
        {value: "NO", text:'NO', output:'<span class="icon fa fa-eye-slash text-blue4"></span>'}
    ]
});

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

No branches or pull requests

3 participants