Monday, May 20, 2024
69
rated 0 times [  73] [ 4]  / answers: 1 / hits: 51508  / 14 Years ago, sun, january 16, 2011, 12:00:00

I have the following function for using ZenDesk. I'd like to inject my current_user details into the form as follows. (this is my from html.haml template). However I cannot figure out how to make this work.



:javascript
if (typeof(Zenbox) !== undefined) {
Zenbox.init({
dropboxID: xxxxx,
url: xxxxx.zendesk.com,
tabID: support,
tabColor: black,
tabPosition: Left,
requester_name: =current_user ? #{current_user.first_name} #{current_user.last_name} : ,
requester_email: =current_user ? #{current_user.email} : ,
hide_tab: true
});
}


In short, how does one inject rails variables into a :javascript element in haml.


More From » ruby-on-rails

 Answers
272

This should work ie. put all inline ruby inside of #{}:



requester_name:  #{current_user.first_name + ' ' + current_user.last_name if current_user},
requester_email: #{current_user.email if current_user},

[#94203] Friday, January 14, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
daquanmilesw

Total Points: 57
Total Questions: 102
Total Answers: 110

Location: Wallis and Futuna
Member since Sat, Aug 6, 2022
2 Years ago
daquanmilesw questions
;