Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » DOM and ModelAdmin

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2 3 4
Go to End
Author Topic: 4432 Views
  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: DOM and ModelAdmin Link to this post

    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.

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: DOM and ModelAdmin Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: DOM and ModelAdmin Link to this post

    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?

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: DOM and ModelAdmin Link to this post

    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

  • Dave L
    Avatar
    Community Member
    56 Posts

    Re: DOM and ModelAdmin Link to this post

    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!

  • UncleCheese
    Avatar
    4085 Posts

    Re: DOM and ModelAdmin Link to this post

    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
    Avatar
    Community Member
    56 Posts

    Re: DOM and ModelAdmin Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: DOM and ModelAdmin Link to this post

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

    4432 Views
Page: 1 2 3 4
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.