Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="//builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v2.0.0.js"></script>
<script src="//builds.emberjs.com/tags/v1.9.1/ember.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <script type="text/x-handlebars">
    {{key-up-input value=basePrice placeholder='Base Price' key-up="updateMarginPercent" }}
    {{key-up-input value=price placeholder='Price' key-up="updateMarginPercent"}}
    {{key-up-input value=marginPercent placeholder='Margin Percent' key-up="updatePrice"}}
  </script>
</body>
</html>
 
App = Ember.Application.create({
  LOG_ACTIVE_GENERATION: true
});
App.ApplicationController = Ember.Controller.extend({
  basePrice: 100,
  price: 100,
  marginPercent: 0,
  actions: {
    updateMarginPercent: function() {
      debugger;
      this.set('marginPercent', (this.get('price') - this.get('basePrice')) * 100.0 / this.get('basePrice'));
    },
    updatePrice: function() {
      this.set('price', this.get('basePrice') * (this.get('marginPercent') + 100) / 100);
    }
  }
});
    App.KeyUpInputComponent = Em.TextField.extend({
      keyUp: function(event){
        this.sendAction('key-up', event, this.get('value'));
      }
    });
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers