Skip to content

Instantly share code, notes, and snippets.

@BigMcLargeHuge
Last active May 6, 2016 01:53
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Blogpost: formatting numerical input with rails cocoon
<div class="nested-fields">
<%= form_for @model do |f| %>
<%= f.text_field :decimal, label: "Just a number with commas and 2 decimal places", data: {autonumeric: true} %>
<%= f.text_field :dollaz, label: "Standard monitary input", data: {autonumeric: {aSign: '$ ', mDec: 2}} %>
<%= f.text_field :integer, label: "Just an integer with commas", data: {autonumeric: {mDec: 0}} %>
<%= f.text_field :posInt, label: "Positive integer with commas", data: {autonumeric: {vMin: 0}} %>
<%= f.text_field :posDec, label: "Positive decimal with commas and two decimal places", data: {autonumeric: {vMin: 0.00}} %>
<% end %>
</div>
$('div#dynamic').on('cocoon:after-insert', function(e, insertedItem) {
$(document).trigger('refresh_autonumeric');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment