randoum / autonumeric-rails Goto Github PK
View Code? Open in Web Editor NEWautoNumeric.js library with an ujs flavor, ready-to-use for rails.
License: MIT License
autoNumeric.js library with an ujs flavor, ready-to-use for rails.
License: MIT License
I have autonumeric in a _form.html.erb as part of a simple new/edit view, but separator just displays on page reload.
this is how I'm displaying the input:
any advice???
I create an input field like this:
= text_field_tag('test', 0, { data: {autonumeric: {aSign: '$ ', mDec: 0, wEmpty: 'sign', lZero: 'deny'}}})
I then update the value from javascript like this:
$("#test").autoNumeric('set', 4000)
The number changes to $ 4000 in the visible formatted input field as expected.
But the value of the hidden input does not change - so when the form is submitted the correct value does not get submitted.
I have two terminals, one is running "rails server", the other one "rails console". The second one, when starting the console, outputs this error message:
** ERROR: directory is already being watched! **
Directory: /my/path/.rvm/gems/ruby-2.3.1@project/gems/autonumeric-rails-1.9.46/spec/dummy/spec
is already being watched through: /my/path/.rvm/gems/ruby-2.3.1@project/gems/autonumeric-rails-1.9.46/spec
MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
Any ideas what would cause this?
I get the following error after upgrading to autonumeric2
ActionController::RoutingError (No route matches [GET] "/assets/autoNumeric.min.js.map")
It's due to the following line in autoNumeric-2.0.js
//# sourceMappingURL=autoNumeric.min.js.map
not working for new element created dynamically.
The following error occurs when assets are precompiled
Sprockets::FileNotFound: couldn't find file 'autonumeric'
The original project provides a way to use the autonumeric fashion without attaching it to an input through the ES6 module calls. Is there something similar that's available here? Even if through jQuery and without ES6 imports?
Thanks!
I think right now the way to set defaults is as mentioned on the autoNumeric page:
$(document).ready(function () {
$.extend($.fn.autoNumeric.defaults, {
aSep: '@System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberGroupSeparator',
aDec: '@System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator',
aSign: '@System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencySymbol'
});
$('selector').autoNumeric('init');
});
Is there a way to set these defaults easier through this gem?
If not, that would be my feature request.
Of course setting global defaults is easy enough, I want an easy way to do this in dynamically in Rails, like updating it in the controller some way.
With 1.9.46 I'm getting this error when trying to install the gem:
Gem::Package::PathError: installing into parent path /my/path/.rvm/gems/ruby-2.3.1@project/spec of
/my/path/.rvm/gems/ruby-2.3.1@project/gems/autonumeric-rails-1.9.46 is not allowed
An error occurred while installing autonumeric-rails (1.9.46), and Bundler cannot continue.
Make sure that `gem install autonumeric-rails -v '1.9.46'` succeeds before bundling.
With 1.9.43 everything works perfectly.
In the following example, I'm trying to do a fallback when a touch device is detected and the browser supports the input type number.
The problem is that, even after the autoNumeric('destroy') is called, the browser console still gives this error, after the user inputs some number and focus outside the input form:
Error: You must initialize autoNumeric('init', {options}) prior to calling the 'get' method
$(document).ready(function(){
// Changes input type to number and disables autonumeric, to use the native
// data input number type.
if (Modernizr.touch && Modernizr.inputtypes.number) {
$('.number-input-field').removeAttr('data-autonumeric');
$('.number-input-field').autoNumeric('destroy');
$('.number-input-field').attr('type', 'number');
$(document).trigger('refresh_autonumeric');
}
});
First, your gem is simple amazing :D, but I have a little bug when I use it with turbo links, have you any solution to make it works?, because for now only works if I reload all the page
Hi All,
I'm using the rails autonumeric plugin and it works great on everything except for dynamically generated fields. It seems that when a new field is added (with cocoon in my case or by some other means) the hidden input is not created if you run the initialize process as recommended by the autonumeric wiki.
$('table#captable').on('cocoon:after-insert', function(e, insertedItem) {
$(item).find('td.numeric input:visible').autoNumeric('init', {vMin: '0', vMax: '99999999', aSep:','});
$(item).find('td.dollars input:visible').autoNumeric('init', {asign: '$', mDec:','});
});
Is there a good way to handle dynamically added fields in this gem?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.