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 6669217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:07:27+00:00 2026-05-26T03:07:27+00:00

I’ve recently begun working in Sproutcore, which seems to be a really good solution

  • 0

I’ve recently begun working in Sproutcore, which seems to be a really good solution for client side web app development. However, the documentation isn’t as thorough or concise as I’d like, so I am struggling with a few things.

Specifically, I’m trying to bind the layout property of one of my views to an object. I’ve managed this to an extent, in that when the view is rendered it uses the properties from the object, but the problem I’m having is that when the object is updated, the view’s dimensions don’t change. However, if the change is persistent and I reload the page, it uses the new values.

Is there some sort of limitation in binding layout properties so that they dynamically update, or do I have the wrong approach here?

  • 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-05-26T03:07:28+00:00Added an answer on May 26, 2026 at 3:07 am

    I’m not sure this approach will work. Controllers are not supposed to have anything to do with a view’s properties; controllers are ONLY supposed to proxy objects.

    One alternative you might want to consider is using the adjust method defined on the SC.View class. You can have your view observe a property on the model it represents, and then in the observer call

    this.adjust('height', 30); // or whatever

    I think adjust can also be used like

    this.adjust({
        height: 10,
        width: 20,...
    })
    

    without knowing more about what you are trying to do, its hard to say more.

    MORE DETAIL

    Ok, so one thing about Sproutcore is you need to be careful to not get in the way of the runloop. Unfortunately, there isn’t much documentation on this. What I have learned is that you wan’t observers to observe things in in their scope only. So here is an outline of what you want to do.

    SC.View.extend({
       layout: {...}, // initial properties
    
       // binding to the text field that adjusting depends on, NOT on 
       // this view's content
       outsidePropertyBinding: "binding.to.textField", 
    
       outsidePropertyDidChange: function(){
           var outsideProperty = this.get('outsideProperty');
           this.adjust({
              // as shown before
           })
       }.observes('outsideProperty') // <-- this is how you create an observer
    
    });
    

    What I’ve shown here is how to adjust based on something that is changing outside of this view. I created

    1) A binding to the outside property, which SC updates for you
    2) An observer on the bound property, that fires as soon as the value is set, and adjusts the view. The observer is observing a property in the view, not out of the view.

    Note that if your view is bound to some content, and its a property on that content itself that changes, then you would do it slightly differently. You wouldn’t need the binding to the outside property, you could instead just observe '*content.relevantproperty'. The * before content tells the observer that the content object itself might change (if the views content object can change).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
I am writing an app with both english and french support. The app requests
I am using Paperclip to handle profile photo uploads in my app. They upload

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.