7912 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » DOM and ModelAdmin
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | Next > | |
| Author | Topic: | 3865 Views |
-
Re: DOM and ModelAdmin

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.
-
Re: DOM and ModelAdmin

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 -
Re: DOM and ModelAdmin

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?
-
Re: DOM and ModelAdmin

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 -
Re: DOM and ModelAdmin

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!
-
Re: DOM and ModelAdmin

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.
-
Re: DOM and ModelAdmin

21 November 2009 at 5:22pm Last edited: 21 November 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.jsAll 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.
-
Re: DOM and ModelAdmin

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.
| 3865 Views | ||
| Go to Top | Next > |

