Hi I am attempting to run a create.js.erb file when a user creates a record inside a RoR app.
Here is the jquery:
$('input[id=bizid]').val("<%= @branch.business_id %>");
$('input[id=braid]').val("<%= @branch.id %>");
Here is the view:
<input style="display:none;" id="bizid" name="bizid" value="" />
<input style="display:none;" id="braid" name="braid" value="" />
I have also tried this:
$('#bizid').val("<%= @branch.business_id %>");
$('#braid').val("<%= @branch.id %>");
<input type="hidden" id="bizid" name="bizid" value="">
<input type="hidden" id="braid" name="braid" value="">
I know that the machinery is working because I use @branch to update another text input field in the same form, without any issue. Also, I checked the DB and the above values for @branch do exist, and should be ready to pass.
Thanks!
EDIT:
alert("<%= @branch.business_id %>");
alert("<%= @branch.id %>");
The above (placed in create.js.erb) results in the correct id #s in two alert dialogs.
$('#bizid').val('my id');to see if that works?$(document).ready(function(){/*yourcode*/});