appMobi/jQ.Mobi — Issue #44: Trigger not working : DOM errors
Author: Indiepath
Created: 2012-01-27 09:25:50+00:00
State: open

I would do a commit but for some reason my pull requests don't seem to be appearing.

Here's the fix:
```javascript
trigger: function (event, data) {
if (this.length === 0) return this;
if (typeof (event) === "string") {
var evtName = event;
var newEvent = document.createEvent("Event");
newEvent.type = evtName;
newEvent.target = this[0];
newEvent.initEvent(evtName, false, true);
newEvent.data = data;
this[0].dispatchEvent(newEvent);
return this;
}
event.data = data;
this[0].dispatchEvent(event);
return this;
},
```