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
onclickattribute (and its value) will be turned straight into an HTML attribute, so if you want to have it run both the callback inlist_eventand 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_eventhelper to also run_LT._trackEvent(_eventType.clickThrough)"#{list_event(params[:item_key])}; _LT._trackEvent(_eventType.clickThrough)"track_eventand call them as"#{list_event(params[:item_key])}; #{track_event}"track_eventhelper and then create a third helper to wrap them both, something likelist_and_track_event, then call that insteadPersonally I'd go with options 1 or 4 depending on the semantics of the two callbacks.