Opened 12 years ago

Closed 12 years ago

#6897 closed bug (notabug)

jquery events fire multiple times when used in dialog

Reported by: nihilnovi Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.dialog Version: 1.8.9
Keywords: Cc:
Blocked by: Blocking:

Description

$('.ordermenu').click(function(event) {

$('.ordermenu-dialog').dialog('open'); ajax_data = {}; ajax_dataorderid? = $(this).prevAll('.deleteorder_checkbox').val(); ajax_dataprice? = $(this).prevAll('.orderrow-price').val(); $('.ordermenu-confirmorder').click(function(event) {

alert(event.type); ajax_dataaction? = 'confirm';

$.ajax({

type: "POST", url: "../callsystem/Ajax_confirmorder/", data: ajax_data, success: function(data) { everytime you close and reopen the dialog, this event fires an additional time next time you click on the handler. }

});

});

$('.ordermenu-unconfirmorder').click(function(event) {

ajax_dataaction? = 'unconfirm';

$.ajax({

type: "POST", url: "../callsystem/Ajax_confirmorder/", data: ajax_data, success: function(data) {

everytime you close and reopen the dialog, this event fires an additional time next time you click on the handler.

}

});

}); makulerad = $(this).prevAll('.orderrow-makulerad');

if(makulerad.val() == "1") {

$('.ordermenu-makuleraorder').attr("checked","true");

} else {

$('.ordermenu-makuleraorder').attr("checked", false);

}

$('.ordermenu-makuleraorder').click(function(event) {

if($(this).attr("checked") == true) {

makulerad.val("1");

ajax_dataaction? = 'makulera'; $.ajax({

type: "POST", url: "../callsystem/Ajax_confirmorder/", data: ajax_data, success: function(data) {

everytime you close and reopen the dialog, this event fires an additional time next time you click on the handler.

}

});

} else {

makulerad.val("0"); ajax_dataaction? = 'unmakulera'; $.ajax({

type: "POST", url: "../callsystem/Ajax_confirmorder/", data: ajax_data, success: function(data) {

everytime you close and reopen the dialog, this event fires an additional time next time you click on the handler.

}

});

}

});

});

html: <div class="red orderrow clickrow">

<input type="checkbox" value="518" class="deleteorder_checkbox"> <input type="hidden" value="1" class="orderrow-makulerad"> <input type="hidden" value="0" class="orderrow-price"> <h4>foo</h4> <span>24-01-2011</span> <div class="ordermenu"></div> </div>

dialog:

<div class="ordermenu-dialog" title="Ordermeny">

<button class="btn btn-grey ordermenu-confirmorder">foo</button> <button class="btn btn-grey ordermenu-unconfirmorder">bar </button> <br /><br /> <p>Makulerad: <input type="checkbox" class="ordermenu-makuleraorder" /></p>

</div>

dialog js:

$('.ordermenu-dialog').dialog({

height: 150, width: 400, modal: true, autoOpen: false

});

bonus: seriously, this has to be the worst WYSIWYG editor I have ever seen, I gave up trying to format the code since it was unintuitive and way too time consuming. I thought jquery ui was proper but this whole dev section seems slapped together by a amateur.

Change History (1)

comment:1 Changed 12 years ago by Scott González

Resolution: invalid
Status: newclosed

This is not a bug. You're binding an additional click handler on every click. Also, please don't complain about this editor, it's not meant for you to dump a ton of code in. There's a message about that on the ticket creation page.

Note: See TracTickets for help on using tickets.