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

  • SEARCH
  • Home
  • 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 8592513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:46:04+00:00 2026-06-11T23:46:04+00:00

Sorry about the long and convoluted title, but I couldn’t summarize it better. I

  • 0

Sorry about the long and convoluted title, but I couldn’t summarize it better.

I have a simple model, with a property foo, initialized to null.

In my view, I don’t want to display an input field when foo is null or "", and have a button that says Add foo.

<a href="#" class="btn" {{action addFoo obj}}> Add foo </a>

{{#if obj.foo}}
  {{view Ember.TextField valueBinding="obj.foo"}}
{{/if}}

Then in my action addFoo, I do:

obj.set('foo', 1);

and that will make the input field appear.

I have two problems with this approach:

  1. 1 is really an arbitrary value, it doesn’t have any special meaning in my application.
  2. If the user deletes 1 because they want to type 2, the input field will disappear before they have the time to type 2.

Is there a better approach to this kind of user interaction?

  • 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-11T23:46:05+00:00Added an answer on June 11, 2026 at 11:46 pm

    I ended up adding a computed property to my model:

    fooIsSet: function() { return this.get('foo') !== null }.property('foo')
    

    So that in my handlebars template I could do this:

    {{#if obj.fooIsSet}}
      do stuff
    {{/if}}
    

    This way I can deal with null only, and '' will act as if the property is set and valid.

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

Sidebar

Related Questions

Sorry about the title, I couldn't think of a better way to describe the
(sorry about the long title) I have a custom object Person, which in turn
sorry about the long title! I have a windows server 2003. I want to
Sorry for the long title but couldn't think of a good way to put
Sorry for long title, the question is rather simple: I have 2 classes, Player
First of all, I'm sorry about the title. I couldn't find a better one.
Sorry about a vague title, but here's what i am trying to do. I
Sorry about the extremely vague question title (any suggestions for improvements welcome) I have
Sorry about the wording for my question title. I have a basic HTML anchor
First off, sorry about the long post. Figured it's better to give context to

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.