Skip to forum content

Mif

— mystic javascript interface

You are not logged in. Please login or register.


Post new reply

Post new reply

Compose and post your new reply

You may use: BBCode Images Smilies

All fields labelled (Required) must be completed before the form is submitted.

Required information for guests



Captcha image. Turn pictures on to see it.
Required information
Optional post settings

Topic review (newest first)

1

Aha, I think it might have something to do with my data... I'm verifying it now...


  • UPDATE 1: rev 103 works fine... I replaced my JSON source to a source that is known to be good and everything works as intended.  Now I only need to know what's wrong with my JSON... missing fields, perhaps?

  • UPDATE 2: OK, I discovered the problem... it turns out that I set some children fields as an empty array...

"children":[{"interfaceopt":"wan","name":"wan0","children":[]}]

2

Yikes, I forgot about Tree_serial:

var Tree_serial = new Class({
    Extends     : Mif.Tree,
    serialize   : function (items) {
        var serial = [];
        if (!items) {
            items = this.root.getChildren();
        }
        items.each(function (el, i) {
            var tmp = new Hash({
                    interfaceopt    :   el.interfaceopt,
                    name            :   el.name,
                    scheduler       :   el.scheduler,
                    enabled         :   el.enabled,
                    bandwidth       :   el.bandwidth,
                    bandwidthtype   :   el.bandwidthtype,  
                    children        :   (el.getChildren()) ? this.serialize(el.getChildren()) : []
            });

            serial[i] = tmp.filter(function (v, k) {
                return !(v === '' || v === null || v === undefined);
            });

        }, this);

        return serial;
    }
});

3

Tree_serial?

4

I've browsed throught the Demos folder in the trunk version, and I discovered that I needed to change my code.  Anyway, this code still doesn't work:

window.addEvent('domready', function () {
    tree = new Tree_serial({
        container   : $('tree_container'),
        types       : {
            folder  : {
                openIcon    : 'mif-tree-open-icon',
                closeIcon   : 'mif-tree-close-icon'
            }
        },
        dfltType    :   'folder',
        height      :   20
    })
    .load({
        url: '/my/json'
    });

    $('add_node').addEvent('click', function () {
        var node = tree.getSelected();
        var newNode = new Mif.Tree.Node({
            parentNode: node,
            tree: tree
        }, {property:{name: 'node1'}});

        tree.add(newNode, node, 'inside');
    });
});

5

BTW, My MooTools version is:

        'version': '1.2.3',
        'build': '4980aa0fb74d2f6eb80bcd9f5b8e1fd6fbb8f607'

6

Hi,

I've upgraded my Mifjs tree copy to rev 103.  Now, whenever I add new nodes, I get the following error:

this.children.each is not a function        Line 388

The vicinity around line 388 is:

        recursive: function(fn, args){
                args=$splat(args);
                if(fn.apply(this, args)!==false){
                        this.children.each(function(node){
                                if(node.recursive(fn, args)===false){
                                        return false;
                                }
                        });
                }
                return this;
        }

What gives?

Thanks!