sferik/rails_admin — pull request #1671 by scarfaceDeb (2013-06-13 18:33:12+00:00)
Title: Replaced global selectors in $ function in rails_admin.dom_ready event h...

I noticed that event handlers on `rails_admin.dom_ready` contain code that init jQuery plugins with css selectors like this: `$('form [data-...]')`.
These handlers are being called when you add new tab in has_many forms. (inside handler for `nested:fieldAdded`).
And you don't need to init all plugins in the form. Only the ones that was added.
That's why when I'm passing additional scoping variables to event handlers that help to narrow scope of css selectors.
It affects nested-form and remote-form handlers.

---
You can use scoping in your custom event handlers for `rails_admin.dom_ready` too.
Like this:
``` js
$(document).on( 'rails_admin.dom_ready', function( e, content ){
var content = content ? content : $('form');

// initialize tagit plugin as an example.
content.find('.comma-separated').tagit();
});
```

--
I've found another `rails_admin.dom_ready` event handler in ui.js:61, but I'm not sure if it needs to be scoped like this.