formatSelection behaving incorrectly #400

Closed
jacobh opened this Issue Sep 12, 2012 · 4 comments

Comments

Projects
None yet
2 participants
Contributor

jacobh commented Sep 12, 2012

In a project I'm working on I have the following options set:

formatResult: (stock, container) ->
    ($ container).append $ "<div class='stock-match'>
        <h3><div class='symbol'>#{stock.code}</div>#{stock.name}</h3>
        <div class='price-details'>
            <div class='overflow-fadeoff'></div>
            <div class='price-last'>#{stock.price_pretty}</div>
            <div class='price-change #{stock.direction}'><div class='price-icon'></div>#{stock.price_change_pc_pretty}</div>
        </div>
    </div>"
    return

formatSelection: (stock, container) ->
    ($ container).append $ "<div><div class='stock-information'> 
        <div class='symbol'>#{stock.code}</div>#{stock.price_pretty}
        <span class='price-change #{stock.direction}'>#{stock.price_change_pc_pretty}%</span>
    </div></div>"
    return

formatResult works perfectly as intended

However formatSelection is not working

As far as I can tell from the docks I am using these functions correctly.

I have also tried simply returning the formatted string like so:

formatSelection: (stock, container) ->
    "<div><div class='stock-information'> 
        <div class='symbol'>#{stock.code}</div>#{stock.price_pretty}
        <span class='price-change #{stock.direction}'>#{stock.price_change_pc_pretty}%</span>
    </div></div>"

but that escapes the the &cent; html code.

Any thoughts would be appreciated!

Contributor

ivaynberg commented Sep 13, 2012

can you please provide a jsfiddle so i can see whats going on, thanks.

Contributor

jacobh commented Sep 14, 2012

ok I've got a couple of jsFiddles setup to demonstrate, they don't have any style because I couldn't get it to work correctly... The only data point is LYC so hitting l will bring up the result, and hitting return is the only way to select it.

  1. manually appending both results to the container, formatResult working, formatSelection giving undefined undefined: http://jsfiddle.net/AzfqF/9/
  2. returning strings, &cent; HTML code not rendering: http://jsfiddle.net/AzfqF/7/

thanks.

Contributor

jacobh commented Sep 14, 2012

for point 2 I have disabled escapeMarkup and the ¢ is now rendering correctly, as can be seen here. Point 1 still seems to be a bug though.

ivaynberg added a commit that referenced this issue Sep 18, 2012

Contributor

ivaynberg commented Sep 18, 2012

fixed in master

@ivaynberg ivaynberg closed this Sep 18, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment