jQuery/jQuery UI Infinite Loop
An infinite loop can occur when adding and remove a resizer to a textarea and then removing the textarea.
HTML
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.9.0/jquery-ui.js"></script>
<div>
<p>Click the "Add Remove Resizer" button a few times then click the "Remove Textarea". jQuery and jQuery UI will enter an infinite loop that will cause the browser to crash to the desktop.
</p>
</div>
<br>
<div>
<textarea id="SampleTextArea"></textarea>
</div>
<div>
<button type="button" id="RemoveAddResizer">Add Remove Resizer</button>
<button type="button" id="RemoveTextArea">Remove Textarea</button>
</div>
JavaScript
var bAdd = true;
$('button#RemoveAddResizer').click(function() {
var $textArea;
$textArea = $('textarea#SampleTextArea');
if (bAdd) {
$textArea.resizable({
minWidth: 40,
maxWidth: 40,
minHeight: 20,
handles: 's'
});
} else {
$textArea.resizable('destroy');
}
bAdd = !bAdd;
});
$('button#RemoveTextArea').click(function() {
$('textarea#SampleTextArea').remove();
});