Page 1 of 1

How use a third part js script

Posted: Wed Mar 22, 2023 1:15 am
by onoboa

Grettings,

I need to show a numeric fields with decimal point and thousand separator, I try to use a cleave.js but when I execute the page shows me an error press F12.

Error: .cleave( is not a function

This is my code:

Server Events->Global->All Pages->Page_Head

AddClientScript("jquery/cleave.js");
AddClientScript("jquery/cleave.min.js");

Client Scripts->Global->List Page->Startup Script

$('#x_cantidad,#x_costo,#x_precio,x_subtotal,#x_porc_descuento,#x_descuento,#x_baseimponible,#x_porc_iva,#x_impuesto,#x_total').cleave({ numeral: true, numeralThousandsGroupStyle: 'thousand', autoUnmask: true});

Some one example to use a js library.

Thanks,

Omar


Re: How use a third part js script

Posted: Wed Mar 22, 2023 2:44 pm
by arbei

Note that JavaScripts are loaded asynchronously. If your scripts depends on jQuery, you need to load them after jQuery is loaded. You may read example 5 under Page_Head, e.g.

<script>
loadjs.ready("jquery", function () {
    loadjs("/my/base/path/path/jquery/cleave.js"]); // Replace "my/base/path" with your real base path
});
</script>