Skip to content

Commit

Permalink
Added autonumeric plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
dylandrop committed Nov 9, 2013
1 parent 8fde71a commit 0eb49c7
Show file tree
Hide file tree
Showing 4 changed files with 1,271 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Expand Up @@ -14,3 +14,4 @@
//= require jquery_ujs
//= require_tree .
//= require vines
//= require autoNumeric
12 changes: 12 additions & 0 deletions app/assets/javascripts/items.js.coffee
@@ -1,3 +1,15 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
class @ItemForm
constructor: () ->
$("#item_nonprofit_percentage").autoNumeric('init',
{
aSep: '',
vMax: '100',
vMin: '0'
})
$("#item_price").autoNumeric('init',
{
mDec: '2'
})
10 changes: 8 additions & 2 deletions app/views/items/new.html.erb
Expand Up @@ -25,10 +25,16 @@

<div>
<%= f.label :nonprofit_percentage, "Percentage of revenue to go to the nonprofit" %><br>
<%= f.text_field :nonprofit_percentage, pattern: '([0-9]+\.)?[0-9]+' %>
<%= f.text_field :nonprofit_percentage %>
</div>

<div>
<%= f.submit "Done" %>
</div>
<% end %>
<% end %>

<script>
window.onload = function() {
new ItemForm();
};
</script>

0 comments on commit 0eb49c7

Please sign in to comment.