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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:47:45+00:00 2026-06-16T15:47:45+00:00

I wrote this very simple Ember code, but for some reason the event doesn’t

  • 0

I wrote this very simple Ember code, but for some reason the event doesn’t seem to fire when I press the button. Any tips?

<!DOCTYPE html>

<html>

  <head>
    <title>Test</title>
  </head>

  <body>

    <script type="text/x-handlebars">
      {{#view CounterView}}
        Counter: {{Counter.value}}

        <button {{action "increment"}}>Add 1</button>
      {{/view}}
    </script>

    <script src="jquery-1.7.2.min.js"></script>
    <script src="handlebars-1.0.rc.1.min.js"></script>
    <script src="ember-1.0.pre.min.js"></script>

    <script>
      Counter = Ember.Object.create({
        value: 1,
      })

      CounterView = Ember.View.extend({
        increment: function(event) {
          Counter.incrementProperty('value');
        }
      })
    </script>
  </body>
</html>
  • 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-16T15:47:46+00:00Added an answer on June 16, 2026 at 3:47 pm

    In order to make the event system working, Ember.js needs an application to be created and initialized (the framework does it for you).

    Applying your example to the default Ember.js starting jsfiddle, here is the result:

    Html template:

    <script type="text/x-handlebars" data-template-name="application">
      {{#view MyApp.CounterView}}
        Counter: {{MyApp.counter.value}}
        <button {{action "increment"}}>Add 1</button>
      {{/view}}
    </script>
    

    Javascript:

    //Thanks to @Trek Instructions:
    //The following line creates one listener for each user event (e.g. 'click') and
    //controls event delegation.
    MyApp = Ember.Application.create();
    
    MyApp.counter = Ember.Object.create({
      value: 1
    });
    
    MyApp.CounterView = Ember.View.extend({
      increment: function(event) {
        MyApp.counter.incrementProperty('value');
      }
    });
    

    ​
    Working fiddle: http://jsfiddle.net/6p6XJ/260/

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

Sidebar

Related Questions

I have some very simple sample code like this: $.ajax({ url: 'demo2.htm', success: function(loadeddata){
I wrote this very simple macro to delete all rows when Column P has
I wrote this code for zoom in/out . it works but even with one
I have a very simple little piece of Lua code, which I wrote while
I wrote very simple code: public static void Main (string[] args) { String str=1,0992748756871115E+41;
I'm very new to lucene.net. I wrote this simple console app in C# which
I just wrote a very simple Expect script for wrapping around rsync, but it
I wrote this simple query statement: INSERT INTO merchants ('firstName','lastName') VALUES ('Bob','Smith') Sounds very
I wrote this very simple SP in SQL 2008: Create procedure dbo.GetNextID ( @TableName
still fairly new to ruby, and wrote this very simple recursive function. def test(input)

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.