Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

mojitProxy.config not being updated after mojtiProxy.refreshView #1046

Open
denchen opened this issue Mar 23, 2013 · 1 comment
Open

mojitProxy.config not being updated after mojtiProxy.refreshView #1046

denchen opened this issue Mar 23, 2013 · 1 comment
Assignees

Comments

@denchen
Copy link

denchen commented Mar 23, 2013

When setting ac.instance.config. after a call to mojitProxy.refreshView(), mojitProxy.config does not get updated to reflect new variable.

The relevant portions of my test code:

=== CONTROLLER ===

index: function(ac) {
    var refresh = ac.params.getFromMerged("refresh", undefined);
    if (refresh) {
        Y.log("Setting 'Refreshed!'", "debug", NAME);
        ac.instance.config.refreshtext = "Refreshed!";
    } else {
        Y.log("Setting 'Unrefreshed'", "debug", NAME);
        ac.instance.config.refreshtext = "Unrefreshed";
    }
    Y.log("Calling ac.done with ac.instance.config.refreshtext = " + ac.instance.config.refreshtext, "debug", NAME);
    ac.done();
}

=== BINDER ===

bind: function(node) {
    var me = this,
        button,
        inputfield;

    this.node = node;

    Y.log("Setting input field text to: " + this.mojitProxy.config.refreshtext, "debug", NAME);
    inputfield = node.one("#inputfield");
    inputfield.set('value', this.mojitProxy.config.refreshtext);

    Y.log("Adding button", "debug", NAME);
    button = new Y.Button({
    srcNode: "#refreshbutton",
        on: {
            'click': function () {
                Y.log("Button clicked!", "debug", NAME);
                this.mojitProxy.refreshView({
                    "params": {
                        "url": {
                            "refresh": 1
                        }
                    },
                    "rpc": true
                }, function(err, data) {
                    Y.log("Refresh view successful", "debug", NAME);
                });
            }.bind(this)
        }
    }).render();
},

onRefreshView: function (node, element) {
    Y.log("onRefreshView() called", "debug", NAME);
    this.bind(node, element);
}

=== VIEW ===

<div id="{{mojit_view_id}}">
<input id="inputfield" name="inputfield" />
<button id="refreshbutton" name="refreshbutton">Refresh Page</button>
</div>
@ghost ghost assigned caridy Mar 23, 2013
@caridy
Copy link
Contributor

caridy commented Mar 23, 2013

Workaround, from Yi:

In controller: ac.done(data, Y.mix(meta, {yourVar: xxx}));
In binder: 
mojitProxy.refreshView(params, function(data, meta) {
    var yourVar = meta.yourVar;
});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants