jquery - how to put javascript inside embedded ruby? -


i trying print flash message after user clicks link, shown below in js.erb file.

$('a').click(function(){             <% flash.now[:alert]= "successfully added  "%> this.innerhtml <% "to cart" %>          }) 

i want flash message "successfully added (whatever clicked) cart" having trouble because seems have embed javascript embedded ruby.

it seems have misunderstanding of how erb works. when add ruby code erb file, it's run on server, , output inserted in it's place in plain html sent client. code doing running ruby flash.new[:alert] = "successfully added" , "to cart" on server. , javascript function sent html client is:

$('a').click(function(){     this.innerhtml }) 

which doesn't anything. want send ajax request server javascript function this.innerhtml , run ruby code upon receiving request.

i'm sure last paragraph seems jargon you, give googling ammo. have quite few misunderstandings of how erb works , how flash works, , can't without giant post can't right now. luck googling!


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -