Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

DOM and ModelAdmin


29 Posts   4605 Views


19 August 2009 at 11:32am Community Member, 712 Posts

Actually, since the nested check is a 'per DataObjectManager' check, you should move to to withing the init function and make it a local variable of that DataObjectManager. Otherwise, you won't be able to handle multiple nested/unnested DataObjectManagers very cleanly, and there is the possibility (as above) of the object model not being ready for to test.

In other works, remove line three and add:

$.fn.DataObjectManager.init = function(obj) {
      var $container = $(obj);
      var nested = $container.hasClass('isNested');
      var container_id = '#'+$container.attr('id');

Since nested is only referenced from within this function, it keeps it within scope and removes the need to test for nested before initialisation.


19 August 2009 at 11:36am Community Member, 712 Posts

See the following diff:

Index: dataobject_manager.js
--- dataobject_manager.js   (revision 227)
+++ dataobject_manager.js   (working copy)
@@ -1,6 +1,5 @@
(function($) {

-var nested = $('.DataObjectManager').hasClass('isNested');
$.fn.DataObjectManager = function() {
   this.each(function() {
@@ -9,6 +8,7 @@

$.fn.DataObjectManager.init = function(obj) {
      var $container = $(obj);
+      var nested = $container.hasClass('isNested');      
      var container_id = '#'+$container.attr('id');
      var facebox_close = function() {         
@@ -259,17 +259,11 @@
-if(!nested && $(this).attr('id')) {
- Behaviour.register({
-    '.DataObjectManager' : {
-       initialize : function() {$(this).DataObjectManager();}
-    }
- });
-else {
- $(function() {$('.DataObjectManager').DataObjectManager();});

+   $(this).DataObjectManager();                           

This appears to work for ModelAdmin, and should maintain support for nested DOMs. Want to try it out?



19 August 2009 at 1:09pm 4085 Posts

Seems to be working. Thanks for the catch. I have no idea why the nested var was global. Also did not know that the livequery plugin was installed. That is functionality identical to Behvaior. The reason for the difference in application was because I have intentionally excluded the Behavior object from popup windows to improve their performance. CTF popups are intolerably slow, and I've found it's mostly because of all their javascript overhead.

By the way, I was SURE that $(function() was an alias for $(document).ready(). I've been using the former for years and I've never had a problem. Is there a difference?


19 August 2009 at 1:19pm Community Member, 712 Posts

My apologies, major brain fail, you are correct. $(function(){...}); is the same as $(document).ready(function(){...});

Groovy! Thanks, great module by the way - definitely joins my list of 'must have' modules with any deployment.


Dave L

21 November 2009 at 4:42pm Community Member, 56 Posts


The latest build of DOM I downloaded (r326) is opening up the popup full screen (or redirecting as Hamish mentions) in IE8. Will the above diff fix that? Has the above patch been tested?



21 November 2009 at 5:05pm 4085 Posts

I reconciled that change a while back. What javascript errors are you getting? Make sure dataobject_manager.js is being included in your source.

Dave L

21 November 2009 at 5:22pm (Last edited: 21 November 2009 5:23pm), Community Member, 56 Posts

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)

Message: Object doesn't support this property or method
Line: 192
Char: 5
Code: 0
URI: http://<edited>/dataobject_manager/javascript/facebox.js

All the javascript files are being included properly at the bottom I believe. IE7 is fine.

Thanks so much for this and the ImageGallery modules UncleCheese, they're a real timesaver.


22 November 2009 at 4:20am 4085 Posts

That's true. Facebox is not IE8 compatible. You need to put the IE7 mode meta tag in there.