jQuery UI Widgets › Forums › Dialogs and Notifications › Window › event onclick of a button on window occure more times
This topic contains 1 reply, has 1 voice, and was last updated by nico77 8 years, 10 months ago.
-
Author
-
Good evening to everyone
I’ve window with some jqxinput/date and a jqxbutton. Whe i press the button a php script insert in a table the value filled in jqxinput/date.
If i open the webpage the first time everything is ok, but if i try to use the window again to insert a new row, a click on my jqxbutton will insert two records with same data, if i continue, the next time a click will insert three new rows with same data. Using a alert message i see that the event “onclick” occure one time more when i use the function. Just post a part of code.
Thank you very much for help.function finestra_nuovorifornimento() {
$(“#jqxcalendario”).jqxDateTimeInput({
width: 140,
culture: ‘it-IT’,
theme:’orange’
});$(“#kmper”).val(”)
$.ajax({
url:”km.php”,success:function(result){
//$(“#oldkm”).html(result);
var kmArray = result.split(‘*’);//$(“#oldkm”).val(kmArray [0])
$(“#kmprec”).val(kmArray [0])
$(“#numrif”).html(kmArray [1])},
error: function(richiesta,stato,errori){
alert(errori);
},}) // fine $.ajax
$(“#spesa”).jqxInput({ height: 25, width: 140});
$(“#costo”).jqxInput({ height: 25, width: 140});
$(“#kmtot”).jqxInput({ height: 25, width: 140});
$(“#kmprec”).jqxInput({ height: 25, width: 140, disabled:true});
$(“#kmper”).jqxInput({ height: 25, width: 140, disabled:true});$(“#salvarifornimento”).jqxButton({ height: 25, width: 140,theme:”orange”});
$(“#kmtot”).keyup(function(){
var kmpercorsi= $(“#kmtot”).val()- $(“#kmprec”).val()
if(kmpercorsi>0)
{
$(“#kmper”).val(kmpercorsi)
}}) //fine keyup
$(“#salvarifornimento”).on(‘click’, function (event) {
var nuovadata=DataPhp($(“#jqxcalendario”).val(‘date’))var stringaJson={
data:nuovadata,
qty:$(“#spesa”).val(),
prezzo: $(“#costo”).val(),
km:$(“#kmtot”).val(),
kmper:$(‘#kmper’).val(),
idrif_prec: $(“#numrif”).html()}
$.ajax({
url:”addrif.php”,
type: “GET”,
data: stringaJson,
success:function(result){},
error: function(richiesta,stato,errori){
alert(errori)
},}) // fine $.ajax
$(‘#jqxgrid’).jqxGrid(‘updatebounddata’)
$(“#nuovorifornimento”).jqxWindow(‘close’)})//fine $(“#salvarifornimento”).on(‘click’)
i’ve resolved using this code before bind $(“#salvarifornimento”)
Thank you.
$("#salvarifornimento").unbind().click()
-
AuthorPosts
You must be logged in to reply to this topic.