Skip to content

Instantly share code, notes, and snippets.

@anirudhgaur
Created February 11, 2012 22:43
Show Gist options
  • Save anirudhgaur/1804827 to your computer and use it in GitHub Desktop.
Save anirudhgaur/1804827 to your computer and use it in GitHub Desktop.
sending values from javascript into ruby injection
<input type="button" onclick="myfunction()" value="NEWEdit" />
<script language="javascript" type="text/javascript">
$(function() {
$(document).on('click', '#edit', function() {
$('#he').text($('#posts').data('count'));
});
});
</script>
<div id="posts" data-count="<%= params[:count] %>">
<h2 id='he'></h2>
<input id="count" type="hidden" value="1" />
class PostsController < ApplicationController
# GET /posts
# GET /posts.json
def index
@posts = Post.all
@val=params[:count].to_i
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @posts }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment