Fix #11 : jQuery delegated events for Firefox

This commit is contained in:
Gary Sharp
2013-08-19 17:36:22 +10:00
parent 760aba9cdf
commit 3596d325eb
2 changed files with 41 additions and 40 deletions
@@ -52,7 +52,13 @@
return false; return false;
}); });
var removeComponentConfirmed = function (id, row) { $deviceComponents.on('change', 'input', updateComponent);
$deviceComponents.on('focus', 'input', function () { $(this).select(); });
$deviceComponents.on('click', 'span.remove', removeComponent);
$deviceComponents.on('click', 'span.edit', editComponentJobTypes);
function removeComponentConfirmed(id, row) {
var data = { id: id }; var data = { id: id };
$.ajax({ $.ajax({
url: '@Url.Action(MVC.API.DeviceModel.ComponentRemove())', url: '@Url.Action(MVC.API.DeviceModel.ComponentRemove())',
@@ -70,7 +76,7 @@
} }
}); });
} }
var removeComponent = function () { function removeComponent() {
var componentRow = $(this).closest('tr'); var componentRow = $(this).closest('tr');
var id = componentRow.attr('data-devicecomponentid'); var id = componentRow.attr('data-devicecomponentid');
if (id) { if (id) {
@@ -84,7 +90,7 @@
componentRow.remove(); componentRow.remove();
} }
} }
var updateComponent = function () { function updateComponent() {
var componentRow = $(this).closest('tr'); var componentRow = $(this).closest('tr');
componentRow.find('input').attr('disabled', true).addClass('updating'); componentRow.find('input').attr('disabled', true).addClass('updating');
@@ -143,7 +149,7 @@
}); });
} }
} }
var editComponentJobTypes = function () { function editComponentJobTypes() {
var edit$this = $(this); var edit$this = $(this);
var componentRow = edit$this.closest('tr'); var componentRow = edit$this.closest('tr');
@@ -246,12 +252,6 @@
}); });
$('#CheckboxBulkSelect_dialogUpdateJobTypes').checkboxBulkSelect({ parentSelector: 'div' }); $('#CheckboxBulkSelect_dialogUpdateJobTypes').checkboxBulkSelect({ parentSelector: 'div' });
$deviceComponents.on('change', 'input', updateComponent);
$deviceComponents.on('focus', 'input', function () { $(this).select(); });
$deviceComponents.on('click', 'span.remove', removeComponent);
$deviceComponents.on('click', 'span.edit', editComponentJobTypes);
}); });
</script> </script>
<div id="dialogUpdateJobTypes" title="Update Job Types"> <div id="dialogUpdateJobTypes" title="Update Job Types">
@@ -2,7 +2,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.18033 // Runtime Version:4.0.30319.18051
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
@@ -182,13 +182,19 @@ WriteLiteral(@">
return false; return false;
}); });
var removeComponentConfirmed = function (id, row) { $deviceComponents.on('change', 'input', updateComponent);
$deviceComponents.on('focus', 'input', function () { $(this).select(); });
$deviceComponents.on('click', 'span.remove', removeComponent);
$deviceComponents.on('click', 'span.edit', editComponentJobTypes);
function removeComponentConfirmed(id, row) {
var data = { id: id }; var data = { id: id };
$.ajax({ $.ajax({
url: '"); url: '");
#line 58 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml" #line 64 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
Write(Url.Action(MVC.API.DeviceModel.ComponentRemove())); Write(Url.Action(MVC.API.DeviceModel.ComponentRemove()));
@@ -200,26 +206,25 @@ WriteLiteral("\',\r\n dataType: \'json\',\r\n data
"lert(\'Unable to remove component: \' + d);\r\n }\r\n " + "lert(\'Unable to remove component: \' + d);\r\n }\r\n " +
" },\r\n error: function (jqXHR, textStatus, errorThrown) {\r\n " + " },\r\n error: function (jqXHR, textStatus, errorThrown) {\r\n " +
" alert(\'Unable to remove component: \' + textStatus);\r\n " + " alert(\'Unable to remove component: \' + textStatus);\r\n " +
" }\r\n });\r\n }\r\n var removeComponent = function () {\r\n " + " }\r\n });\r\n }\r\n function removeComponent() {\r\n " +
" var componentRow = $(this).closest(\'tr\');\r\n var id = compo" + " var componentRow = $(this).closest(\'tr\');\r\n var id = componentRow" +
"nentRow.attr(\'data-devicecomponentid\');\r\n if (id) {\r\n " + ".attr(\'data-devicecomponentid\');\r\n if (id) {\r\n var dia" +
"var dialog = $(\"#dialogConfirmRemove\");\r\n var buttons = dialog.di" + "log = $(\"#dialogConfirmRemove\");\r\n var buttons = dialog.dialog(\"o" +
"alog(\"option\", \"buttons\");\r\n buttons[\'Remove\'] = function () { re" + "ption\", \"buttons\");\r\n buttons[\'Remove\'] = function () { removeCom" +
"moveComponentConfirmed(id, componentRow); $(this).dialog(\"close\"); };\r\n " + "ponentConfirmed(id, componentRow); $(this).dialog(\"close\"); };\r\n " +
" var buttons = dialog.dialog(\"option\", \"buttons\", buttons);\r\n " + "var buttons = dialog.dialog(\"option\", \"buttons\", buttons);\r\n dial" +
" dialog.dialog(\'open\');\r\n } else {\r\n // New - Remove" + "og.dialog(\'open\');\r\n } else {\r\n // New - Remove\r\n " +
"\r\n componentRow.remove();\r\n }\r\n }\r\n var " + " componentRow.remove();\r\n }\r\n }\r\n function up" +
"updateComponent = function () {\r\n var componentRow = $(this).closest(" + "dateComponent() {\r\n var componentRow = $(this).closest(\'tr\');\r\n " +
"\'tr\');\r\n componentRow.find(\'input\').attr(\'disabled\', true).addClass(\'" + " componentRow.find(\'input\').attr(\'disabled\', true).addClass(\'updating\');\r\n\r" +
"updating\');\r\n\r\n var id = componentRow.attr(\'data-devicecomponentid\');" + "\n var id = componentRow.attr(\'data-devicecomponentid\');\r\n " +
"\r\n if (id) {\r\n // Update\r\n var data = {" + "if (id) {\r\n // Update\r\n var data = {\r\n " +
"\r\n id: id,\r\n Description: componentRow.fin" + " id: id,\r\n Description: componentRow.find(\'input.descr" +
"d(\'input.description\').val(),\r\n Cost: componentRow.find(\'inpu" + "iption\').val(),\r\n Cost: componentRow.find(\'input.cost\').val()" +
"t.cost\').val()\r\n };\r\n $.ajax({\r\n " + "\r\n };\r\n $.ajax({\r\n url: \'");
" url: \'");
#line 100 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml" #line 106 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
Write(Url.Action(MVC.API.DeviceModel.ComponentUpdate())); Write(Url.Action(MVC.API.DeviceModel.ComponentUpdate()));
@@ -254,7 +259,7 @@ WriteLiteral(@"',
url: '"); url: '");
#line 126 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml" #line 132 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
Write(Url.Action(MVC.API.DeviceModel.ComponentAdd(null, null, null))); Write(Url.Action(MVC.API.DeviceModel.ComponentAdd(null, null, null)));
@@ -280,7 +285,7 @@ WriteLiteral(@"',
}); });
} }
} }
var editComponentJobTypes = function () { function editComponentJobTypes() {
var edit$this = $(this); var edit$this = $(this);
var componentRow = edit$this.closest('tr'); var componentRow = edit$this.closest('tr');
@@ -294,7 +299,7 @@ WriteLiteral(@"',
url: '"); url: '");
#line 157 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml" #line 163 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
Write(Url.Action(MVC.API.DeviceModel.Component())); Write(Url.Action(MVC.API.DeviceModel.Component()));
@@ -322,7 +327,7 @@ WriteLiteral("\',\r\n dataType: \'json\',\r\n
"ajax({\r\n url: \'"); "ajax({\r\n url: \'");
#line 181 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml" #line 187 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
Write(Url.Action(MVC.API.DeviceModel.ComponentUpdateJobSubTypes())); Write(Url.Action(MVC.API.DeviceModel.ComponentUpdateJobSubTypes()));
@@ -364,11 +369,7 @@ WriteLiteral("\',\r\n dataType: \'json\',\r\n
"\r\n },\r\n Cancel: function () {\r\n " + "\r\n },\r\n Cancel: function () {\r\n " +
" $(this).dialog(\"close\");\r\n }\r\n }\r\n });\r\n\r\n " + " $(this).dialog(\"close\");\r\n }\r\n }\r\n });\r\n\r\n " +
" $(\'#CheckboxBulkSelect_dialogUpdateJobTypes\').checkboxBulkSelect({ parentSel" + " $(\'#CheckboxBulkSelect_dialogUpdateJobTypes\').checkboxBulkSelect({ parentSel" +
"ector: \'div\' });\r\n\r\n $deviceComponents.on(\'change\', \'input\', updateCompon" + "ector: \'div\' });\r\n });\r\n</script>\r\n<div");
"ent);\r\n $deviceComponents.on(\'focus\', \'input\', function () { $(this).sele" +
"ct(); });\r\n\r\n $deviceComponents.on(\'click\', \'span.remove\', removeComponen" +
"t);\r\n $deviceComponents.on(\'click\', \'span.edit\', editComponentJobTypes);\r" +
"\n });\r\n</script>\r\n<div");
WriteLiteral(" id=\"dialogUpdateJobTypes\""); WriteLiteral(" id=\"dialogUpdateJobTypes\"");