I'm trying to work out where I should put the following snippets of code in my Rails 4 app in order for them to be included in the asset pipeline.
The following is used on my form:
<input id="tag" type="text" name="tags" value="">
<p>
<a class="tag">aaa</a><br/>
<a class="tag">bbb</a><br/>
<a class="tag">ccc</a><br/>
<a class="tag">ddd</a><br/>
<a class="tag">eee</a>
</p>
Where should the following code be placed so that is is triggered by the above html?:
$('a.tag').live('click', function(e){
$('#tag').val(this.innerHTML);
return false;
});
Here is working example http://jsfiddle.net/Kaf3V/4/
UPDATE: The JS, is being loaded correctly, but simply doesn't work in Rails 4(?)
Thanks
.on()at some point. The syntax is$('#aParentElement').on('click', '#targetElement', function(e){. Just a thought. EDIT, linklive have been removed from the new versions of jquery, so any update the jquery script would brake the script.