Bindings over aspx main page and ascx control page

103 views
Skip to first unread message

lre...@gmail.com

unread,
Nov 16, 2012, 11:32:08 AM11/16/12
to knock...@googlegroups.com
I'm currently developing an web application that has some UI controls that I need to be binded by Knockout.

The structure is the following: MainPage.aspx -> _manageStructures.ascx -> _editStructure.ascx;

All of these render in the same page, adding the new components by AJAX.

The MainPage binding works perfectly, but the _editStructure doesn´t seem to get the binding values.

What I've done was create a ModelView.js file that has the two ViewModels that I need in my app, and then a "NameSpace" function that returns a global object.

function v1 (name){
 this.name = ko.observable(name);
}

function v2(views){
 this.views = ko.observable(views);
}

function NameSpace() { }

var global = new NameSpace();

So, when I need to apply some binding what I do is:

var v  =new V1("luis");
global.v1 = v;

ko.applyBindings(global);

Then, on my HTML what I do is:

<input data-bind="value: v1.name" />

Now, the problem is that I can only make it work on the Main Page.

When I try to bind V2 values to inputs on my EditPage, the value is allways null.

Can someone give me some pointers on what I should try to make it work?

Tks



Luis Rente

unread,
Nov 16, 2012, 11:39:35 AM11/16/12
to knock...@googlegroups.com
Another thing I wish to point out is this

In my _manageStructure.ascx I have an action link that will render the _editStructure in the web page when clicked.
When I do this in the same page it doesn´t work, but if I open it  on a new tab it works perfectly...
Reply all
Reply to author
Forward
0 new messages