Skip to content

sending wildcards to the viewmodel with requireVM #100

@maxfridbe

Description

@maxfridbe

I am following the common requieVM pattern and am having an issue accessing the property set.

<div class="viewServer" data-bind="page:{id:'viewServer'}" >
                <div data-bind="page:{id:'?', nameParam:'Address', sourceOnShow:'/views/servers/viewServer.html', withOnShow:requireVM('/viewmodels/servers/viewServerViewModel.js')}">

                </div>
            </div><!--END PAGE-->

This hit's twice in pagerjs:

 if (this.ctx[nameParam]) { // set observable ...
                            this.ctx[nameParam](this.currentId);
                        } else { // ... or create observable
                            this.ctx[nameParam] = ko.observable(this.currentId);
                        }

First it creates a new observable because context is not set.
Then it sets the observable.

In the VM doing:

 self.Address.subscribe(function(newval){
            alert(self.Address());
        });

Does nothing, as the self.Address gets overwritten.

When trying to get to #/viewserver/ipaddress

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions