I need to get this piece of js to fire on a click event:
"_LT._trackEvent(_eventType.clickThrough)"
Need to add it to this eruby tag which already has an onclick event:
<%= submit_tag 'Send enquiry', :class => "BtnSubmit", :onclick => list_event(params[:item_key])%>
How would I go about doing this?
The onclick
attribute (and its value) will be turned straight into an HTML attribute, so if you want to have it run both the callback in list_event
and this other callback, you'll need to join them together in such a way that the JS will run both.
I can see a few decent options for this:
list_event
helper to also run _LT._trackEvent(_eventType.clickThrough)
"#{list_event(params[:item_key])}; _LT._trackEvent(_eventType.clickThrough)"
track_event
and call them as "#{list_event(params[:item_key])}; #{track_event}"
track_event
helper and then create a third helper to wrap them both, something like list_and_track_event
, then call that insteadPersonally I'd go with options 1 or 4 depending on the semantics of the two callbacks.