title = ->
$("#post_title").keyup ->
@value
When I try to call to title()
function I'm getting [object Object]
.
I have to add to the function value to this code:
"<li>" + "<div class='btn-group'>" + "<a href='/en" + "/posts/preview_search/" + "?post[title]=" + title() + "</a>" + "</div>" + "</li>"
How can I get the @value
returned by the object instead of the object?
Thanks!
The keyup event will happen after the function returns, therefore it can't be assigned to title
using the function's return value. One way would be to do whatever you need to do with title
inside the function:
$("#post_title").keyup ->
title = @value
# use title
Try:
title = ->
$("#post_title").keyup (e) ->
$(e.target).attr 'value'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.