0

Requirement:

I need to preserve white space in a response i receive from backend, use the response as input for select dropdown in my UI and need to send the user selection to backend again.

Problem:

The white-space css property didn't worked for me. Though replacing spaces with &nbsp worked, i can't use that solution, Since the input i receive is large and replacing all spaces with &nbsp requires lot of computation. There were other framework issues too.

Question:

Is there any other solution to preserve white spaces in an HTML select option other than javascript way of using &nbsp?

Shankar
  • 27
  • 6
  • I believe that this will help you [stackoverflow][1] [1]: http://stackoverflow.com/questions/8994516/html-css-best-practice-for-preserving-white-space-on-certain-elements – Paulo Lima Feb 11 '14 at 19:12
  • I dont think there is any solution other than using ` ` – Zword Feb 11 '14 at 19:13
  • @Paulo Lima - I tried White-space: pre and White-space: pre-wrap with an example before. Somehow the white-space property is not working for select. I am not sure why – Shankar Feb 11 '14 at 19:16
  • @Shankar white-space will not work for select – Zword Feb 11 '14 at 19:17
  • @Paulo Lima - Please find the JS Fiddle below http://jsfiddle.net/sankarpeddi/EuVQ2/ – Shankar Feb 11 '14 at 19:32
  • I'm sorry for what I see is only via javascript yourself, because the option does not let the css seems to act – Paulo Lima Feb 11 '14 at 19:59

1 Answers1

-1

did you try wrapping it in <pre></pre> tags?

Victor Radu
  • 2,262
  • 1
  • 12
  • 18
  • You mean like ?.. I can't use it that way since i am using Ember.select – Shankar Feb 11 '14 at 19:11
  • seriously your're gonna down vote me even though you never mentioned you use ember and I just took my time to help... not cool anyway if you need the whitespaces only for the submitted data, not for the frontend, try saving the string in javascript and posting it on submit – Victor Radu Feb 11 '14 at 19:17
  • I did not down voted you. I am sorry if it was a mistake. I tried to upvote but i didn't have sufficient points. I do respect you for taking time to help others. – Shankar Feb 11 '14 at 19:20
  • May be it will work to save the string and sending it to submit than sending user selection. Let me give it a try. Thanks for the help! – Shankar Feb 11 '14 at 19:34