Monday, March 22, 2010

jscompress fails to compress my js file and errors out - why?

Issue:

You use the online compression utility jscompress.com to compress your js file but it fails with an error. Why this may be happening and how to fix it.

Possible causes:

Apparently not using open and closing curly brackets in an IF statement would cause this. Well turns out this is not the case. Look at the following example and see if you can figure out what the issue is :-)




function SetupDeliveredVPRecontactNotes($item, id) {
var theData;

$.ajax({
data: { deliveredVPId: id },
url: $('#ajaxGetDeliveredVPRecontactNotesUrl').val(),
type: "GET",
async: false,
dataType: "html",
success: function(data, result) {
$item.empty();

var input = '';
$item.append('input');
theData = data;
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
$item.empty();
alert("An error occurred: The operation to retrieve the DeliveredVP's Recontact Notes has failed");
}
}); //ajax

return theData;
}


Solution:

The issue is the closing textarea tab, concatenate it as

''
will fix the issue

Monday, March 15, 2010

How to check off a checkbox using jQuery

$('#someCheckbox').attr('checked','true')