Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <link href="//cdn.jsdelivr.net/picnicss/4.1.1/picnic.min.css" rel="stylesheet">
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <h1>Hello Mag.JS!</h1>
  <a target="_top" href="https://github.com/magnumjs/mag.js">GitHub</a>
  <hr/>
  <div id="HelloWorld">
    <ui-input>
      <label>Name:</label>
      <input name="hello" placeholder="Enter a name here" />
    </ui-input>
    <hr/>
    <h1>Hello <hello></hello>!?</h1>
  </div>
  <script src="//rawgit.com/magnumjs/mag.js/master/mag-latest.min.js"></script>
</body>
</html>
 
.cloak, .hide {
  display: none;
}
a { display: block;}
a:after {content:" \bb";}
 
/* Mag.JS - Parent Child ui-input component example! */
var UserInputComponent = {
  //Run only once
  didload: function() {
    //User input field
    this.state.input = {
      //Event to collect change
      _onInput: () => {
        this.props.onChange(this.state.hello);
      }
    }
  }
}
var User = mag.module(
  document.querySelector("ui-input"),
  UserInputComponent
)
var DataComponent = {
  controller: function(props) {
    User({
      onChange: (data) => {
        this.data = data;
      }
    })
  },
  view: function(state, props) {
    state.hello = this.state.data || props.default;
  }
}
//Start application
mag.module('HelloWorld', DataComponent, {
  default: 'friend'
});
Output 300px

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

Dismiss x
public
Bin info
anonymouspro
0viewers