Wednesday, September 23, 2009 |
|
|
Tried having a bash with jsUnit today, and got instantly stuck when trying to run a basic test case. FireFox simply hung, and I really had no idea why. For the first time, IE8 worked fine! Thanks to this post, it was straightforward enough to get working. First you have to modify the jsUnitTestManager.js file, and replace/insert the following code: function isFF3() {
return (
navigator.userAgent.toLowerCase().indexOf("iceweasel/3") != -1 ||
navigator.userAgent.toLowerCase().indexOf("firefox/3") != -1
)
}
function browserSupportsReadingFullPathFromFileField() {
return !isOpera() && !isIE7() && !isFF3();
//return !isOpera() && !isIE7();
}Secondly, you'll have to disable the draconian security that new FF introduces. Type about:config in your address bar and then set security.fileuri.strict_origin_policy to false. This will allow FireFox to access local resources without a problem. Now it will have disabled the browse to field, so the only way you can run your tests is directly via the address bar, as so: <path to testrunner.html>?testpage=<path to mytests.html> |
Wednesday, September 23, 2009 9:58:52 AM (GMT Standard Time, UTC+00:00) | | Javascript
|
|
|
|
Tuesday, September 22, 2009 |
|
|
Looking at in-line validation for a new website, came across this cracking jQuery component - http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/Couple of gotchas to remember with this: - It expects the validation class to be FIRST. So you'll need to remove existing classes and then add them back again at the end.
- It has a bug whereby when you resize/move the window the error divs draw in a new position. I've fixed this by modifying the buildPrompt() function as below:
var divErrorId = 'divError_' + linkTofield;
$('#' + divErrorId).remove();
$(divFormError).attr('id', divErrorId);This very simply identifies each error div according to the field it is displaying against, and removes any existing ones before it adds a new one. Best practice would be to do this automatically rather than in-line, so you may want to have a function like so: function registerValidation(id, validation)
{
//validation has to be the first class declared
var elementClassList = $(id).attr('class');
$(id).removeClass(elementClassList);
$(id).addClass(validation);
$(id).addClass(elementClassList);
}call this from doc.ready in your page as so $(document).ready(function() {
registerValidation("#txtMyField", 'validate[required,custom[onlyLetter],length[0,100]]');
I haven't tested the above code to any great degree yet, leave a comment if you spot any goofs! Also, there appears to be another bug if you want to call the javascript directly, so you need to make sure you set the settings like so: var settings = jQuery.extend({ allrules:allRules, inlineValidation: true, ajaxSubmit: false,
promptPosition: "topRight", // OPENNING BOX POSITION,
IMPLEMENTED: topLeft, topRight, bottomLeft, centerRight, bottomRight success : false, failure : function() {} }, settings);
$.validationEngine.loadValidation("#txtAddressLine1", settings);
Then you want to check - Code: Select all
$.validationEngine.isError
for an error. |
Tuesday, September 22, 2009 1:02:53 PM (GMT Standard Time, UTC+00:00) | | Javascript
|
|
|
|
Thursday, September 03, 2009 |
|
|
Came a cropper with this today. Wired up a $.ajax() event to my [button] thinking that all should be well.
Couldn't understand why the ajax call was terminating BEFORE the code on the server side was being called, even though the server side code was actually being called!
Should have known this, but [button] behaves as a Submit button under all browsers except IE, if you don't mark the "type" attribute.
See http://www.w3schools.com/tags/tag_button.asp for more info |
Thursday, September 03, 2009 2:33:52 PM (GMT Standard Time, UTC+00:00) | | ASP.NET
|
|
|
|
|
|
|
| Archive |
| July, 2010 (1) |
| June, 2010 (3) |
| May, 2010 (6) |
| April, 2010 (5) |
| March, 2010 (1) |
| February, 2010 (3) |
| January, 2010 (6) |
| December, 2009 (4) |
| November, 2009 (4) |
| October, 2009 (5) |
| September, 2009 (3) |
| August, 2009 (4) |
| July, 2009 (2) |
| June, 2009 (7) |
| May, 2009 (3) |
| April, 2009 (4) |
| March, 2009 (1) |
| February, 2009 (2) |
| January, 2009 (4) |
| December, 2008 (6) |
| November, 2008 (4) |
| October, 2008 (1) |
| June, 2008 (2) |
| May, 2008 (1) |
| March, 2008 (5) |
| February, 2008 (3) |
|
|
|
|