ded/domready — Issue #10: *hack* to support $(function() {}) shorthand
Author: rvagg
Created: 2011-10-17 23:54:05+00:00
State: open

OK, while this could go into the Ender bridge for domready I'm suspecting that it may be deemed unnecessary so I'm happy for you to close this ticket without action. I'm just putting it here for the record in case someone else finds it useful.

To get someone else's jQuery plugin working with Ender without modifying their code, I've put the following hack in prior to the plugin code. It's for where of $(function() {}) is used as a shorthand for $(document).ready(function() {}).

```javascript
ender = function() {
return (arguments.length && typeof arguments[0] == 'function' ?
enderOrig.domReady : enderOrig).apply(this, arguments)
}
for (p in enderOrig) ender[p] = enderOrig[p]
// this line is only required if $(function(){}) is required outside this Ender build file
// although a $=ender may be required depending on how it's invoked in the local scope
window['$'] === enderOrig && (window['$'] = ender)
```