jquerytools/jquerytools — Issue #616: e.originalEvent not passed after call to invalidate
Author: jpfranco
Created: 2012-01-11 23:36:29+00:00
State: open

Not sure whether this is a bug, but it caused a bug in my code which took me several hours to figure out. Hopefully this will be useful to someone. I was adding a server side validation by calling invalidate as shown below:

```javascript
form.data("validator").invalidate({"username": "Test."});
```
At first I thought that the invalidate function was broken on my version of the library, but then I realized that an exception was being raised elsewhere. I had configured my validator to listen to the *onFail* event in order to focus on the first input that failed:

```javascript
onFail: function(e, els)
{
if (e.originalEvent.type == 'submit')
{
$.each(els, function()
{
var input = this.input;
input.focus();
return false;
});
}
}
```
The problem was that *e.originalEvent* was null when the callback was executed after calling *invalidate*. I added an additional condition to the if statement in order to circumvent this: *e.originalEvent != null*