Skip to content

Commit cb0a2db

Browse files
committed
testStart wrapped in try/catch block to avoid freeze
1 parent d5d8808 commit cb0a2db

File tree

1 file changed

+33
-27
lines changed

1 file changed

+33
-27
lines changed

Mvc.JQuery.Datatables.Example/Scripts/QUnitTests.js

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -103,33 +103,39 @@
103103
QUnit.done(dTAjaxController.cleanup);
104104
QUnit.config.testTimeout = 30000;
105105
QUnit.testStart(function resetElements() {
106-
var context = document.getElementById("testTableHolder");
107-
$("input[type='text']:enabled", context)
108-
.each(function () {
109-
if (this.value !== "") {
110-
this.value = "";
111-
$(this).triggerHandler("keyup");
112-
}
113-
});
114-
$("input[type='checkbox']:enabled", context)
115-
.each(function () {
116-
if (this.checked) {
117-
this.checked = false;
118-
$(this).triggerHandler("click");
119-
}
120-
});
121-
$("select:enabled", context)
122-
.each(function () {
123-
$(this).children().filter(function (indx) {
124-
return (indx == 0 || this.defaultSelected)
125-
}).last()
126-
.each(function () {
127-
if (!this.selected) {
128-
this.selected = true;
129-
this.triggerHandler("change");
130-
}
131-
});
132-
});
106+
try {
107+
var context = document.getElementById("testTableHolder");
108+
$("input[type='text']:enabled", context)
109+
.each(function () {
110+
if (this.value !== "") {
111+
this.value = "";
112+
$(this).triggerHandler("keyup");
113+
}
114+
});
115+
$("input[type='checkbox']:enabled", context)
116+
.each(function () {
117+
if (this.checked) {
118+
this.checked = false;
119+
$(this).triggerHandler("click");
120+
}
121+
});
122+
$("select:enabled", context)
123+
.each(function () {
124+
$(this).children().filter(function (indx) {
125+
return (indx == 0 || this.defaultSelected)
126+
}).last()
127+
.each(function () {
128+
if (!this.selected) {
129+
this.selected = true;
130+
this.triggerHandler("change");
131+
}
132+
});
133+
});
134+
} catch (err) {
135+
if (console && console.log) {
136+
console.log("error on executing QUnit.testStart: " + err.toString());
137+
}
138+
}
133139
});
134140

135141
$(document).ajaxError(function(event, jqXHR, ajaxSettings, thrownError)

0 commit comments

Comments
 (0)