Implementing autoNumeric v4 in MVC Project

944 views Asked by At

I have a problem when I try to install via nuget manager, when I search for 'autonumeric' I can clearly see that the latest version is 1.9.45

When I go to project site, I can see that version 1.9.45 is obsolete. So, I want to get version 4.* but I do not know how. I also tried vie npm install command and nothing.

My question is: How can I download and incorporate the new version of autoNumeric in my MVC Web Project?

Steps:

  1. Download zip from GitHub link

  2. Unzip the folder and navigate to src folder

  3. Copy all files to your solution for example to: Scripts/autoNumeric folder
  4. Add it in your bundle like:

    bundles.Add(new ScriptBundle("~/bundles/autoumeric").Include( "~/Scripts/autoNumeric/AutoNumeric.js", "~/Scripts/autoNumeric/AutoNumericDefaultSettings.js", "~/Scripts/autoNumeric/AutoNumericEnum.js", "~/Scripts/autoNumeric/AutoNumericEvents.js", "~/Scripts/autoNumeric/AutoNumericHelper.js", "~/Scripts/autoNumeric/AutoNumericOptions.js", "~/Scripts/autoNumeric/AutoNumericOptions.js", "~/Scripts/autoNumeric/main.js"));

  5. For testing purposes add in your HTML input field:

    <input type="text" id="test" value="" placeholder="something">
    
  6. Initialize input field in your file. FOr example your main javascript file is main.js (NOTICE: this main.js is different than main.js in autonumeric folder!):

    $(document).ready(function () {
      // Initialization
       new AutoNumeric('#test', { currencySymbol : '$' });
    })
    

This not works. Question: Should I import ES modules from folder or my main.js 'sees' the autoNumeric/main.js and all of its modules?

1

There are 1 answers

1
Baldráni On BEST ANSWER

If you can rely on an internet connection you should probably just use a CDN

Here is the link : https://cdnjs.com/libraries/autonumeric

Simply import it in your body like :

<script src="https://cdnjs.cloudflare.com/ajax/libs/autonumeric/4.1.0/autoNumeric.min.js"></script>

And you should be good using it (don't forget to remove useless files).