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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

DOM and ModelAdmin


Go to End


29 Posts   6785 Views

Avatar
Hamish

Community Member, 712 Posts

19 August 2009 at 11:32am

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.

Avatar
Hamish

Community Member, 712 Posts

19 August 2009 at 11:36am

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() {
 		$.fn.DataObjectManager.init(this);
@@ -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 @@
 $().ajaxStop(function(r,s){  
   $(".ajax-loader").fadeOut("fast");  
 });  
-if(!nested && $(this).attr('id')) {
-  Behaviour.register({
-  	'.DataObjectManager' : {
-  		initialize : function() {$(this).DataObjectManager();}
-  	}
-  });
-}
-else {
-  $(function() {$('.DataObjectManager').DataObjectManager();});
-}
 
+$('.DataObjectManager').livequery(function(){
+	$(this).DataObjectManager();									   
+});
+
 })(jQuery);
 
 

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

Cheers,
Hamish

Avatar
UncleCheese

Forum Moderator, 4102 Posts

19 August 2009 at 1:09pm

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?

Avatar
Hamish

Community Member, 712 Posts

19 August 2009 at 1:19pm

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.

Cheers,
Hamish

Avatar
Dave L

Community Member, 60 Posts

21 November 2009 at 4:42pm

Hi,

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?

Thanks!

Avatar
UncleCheese

Forum Moderator, 4102 Posts

21 November 2009 at 5:05pm

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

Avatar
Dave L

Community Member, 60 Posts

21 November 2009 at 5:22pm

Edited: 21/11/2009 5:23pm

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.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

22 November 2009 at 4:20am

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