lundi 15 juin 2020

How to set value to autonumeric element programmatically?

I use (autonumeric@4.1.0) with laravel 5.7/jquery 3.4.1 app and I need to set value to autonumeric element programmatically on event triggered. Looking at description https://github.com/autoNumeric/autoNumeric

I see example with set method :

anElement.set(42.76);

I have have problems with this was, as in public/js/Backend/bookings-and-availability.js which I attach in blade file I have :

function bookingsAndAvailability(page, paramsArray) {  // constructor of backend bookingsAndAvailability listing - set all from referring page and from server
      // elements init
        ...
        new AutoNumeric('#numeric_check_fees', {
            currencySymbolPlacement: this_current_currency_position,
            currencySymbol: this_current_currency_short,
            maximumValue: '9999999999.99',
            minimumValue: 0.00
        });
        const check_feesAutoNumeric = document.querySelector('#numeric_check_fees');
        check_feesAutoNumeric.addEventListener('autoNumeric:rawValueModified', e => {
            if (typeof e.detail.newRawValue != "undefined") {
                $("#check_fees").val(e.detail.newRawValue)
            }
        });
        ...

// event handling:
bookingsAndAvailability.prototype.feeDictionaryItemSelect = function (selected_value) {

    // anElement.set(42.76);
    check_feesAutoNumeric = document.querySelector('#numeric_check_fees');
    check_feesAutoNumeric.set(selected_value)
}

But I got error :

bookings-and-availability.js?dt=1592282828:1708 Uncaught TypeError: check_feesAutoNumeric.set is not a function
    at bookingsAndAvailability.feeDictionaryItemSelect (bookings-and-availability.js?dt=1592282828:1708)
    at HTMLSelectElement.onchange (bookings-and-availability:991)

Which is a valid way ?

Thanks!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire