Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9288265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:52:29+00:00 2026-06-18T19:52:29+00:00

I have a ko.observableArray and I’ve added a subscriber for items in the observable

  • 0

I have a ko.observableArray and I’ve added a subscriber for items in the observable array:
eventDate.subscribe(function(newDate) { ... }

Within that handler, I have no access to the parent or root of my view model.

When I access this, I get a reference to window. What I would like to do is get access to the scope which contains the observable array. (I have tried normal and fat arrow => in coffeescript for scope).

My reasoning is that I have data that I didn’t want duplicated/referenced within the observable array for each item. I mostly have experience with backbone, so perhaps this is not the “knockout.js” way.

My goal is to have ko.applyBindings new MainModel() instead of adding a reference for my model in window.

I’ve created a jsfiddle to demonstrate:
http://jsfiddle.net/brianzinn/r4bd8/

Thanks. Does anybody know a solution?

Edit

Passing the view model in the constructor gives access to the parent, is this a good practice?
http://jsfiddle.net/brianzinn/r4bd8/7/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T19:52:30+00:00Added an answer on June 18, 2026 at 7:52 pm

    What you should do is pass the parent down through the Row constructor. Then you will have easy access to the Row’s parent.

    It would look something like:

    class Row
        constructor: (parent) ->
        ...
    

    Then you can access parent from within the Row.

    Constructing the Row would change slightly too:

    @rows = ko.observableArray [new Row(this)]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Knockout observable array that I wish to edit from within Javascript
I have an observable array with var items= [ {image: /images/image1.jpg }, {image: /images/image2.jpg
I have an observable array of Services that might be provided by a company
I have a viewModel: var teamViewModel = { teams: ko.observableArray([]), selectedTeam: ko.observable(1), clearTeams: function(){
I have a knockout.js ViewModel with an observable array: function ItemsViewModel() { this.data =
I have a Knockout.JS observable array that is the basis for a list: self.list_elements
I have Knockout.js view model that has nested observable arrays. function ParentVM(data) { var
I have an observable array var myArray = ko.observableArray([ { name: Jimmy, type: Friend,
I am new to Knockout.js, I have created an observable array and initialized with
I have an observable array, bound to the list of contenteditable divs. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.