Skip to main content

Search and Top Navigation

#6897 closed bug (notabug)

Opened January 25, 2011 10:14AM UTC

Closed January 25, 2011 12:52PM UTC

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_data["orderid"] = $(this).prevAll('.deleteorder_checkbox').val();

ajax_data["price"] = $(this).prevAll('.orderrow-price').val();

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

alert(event.type);

ajax_data["action"] = '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_data["action"] = '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_data["action"] = '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_data["action"] = '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.

Attachments (0)
Change History (1)

Changed January 25, 2011 12:52PM UTC by scottgonzalez comment:1

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.