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/>
  <!-- IN & OUT -->
  <div id="outside">
    <h2></h2>
    <h1> <status></status></h1>
    <button>Detach/Reattach</button>
    <span><num></num></span>
    <ol>
      <li></li>
    </ol>
  </div>
  <!-- IN & OUT -->
  <script src="//rawgit.com/magnumjs/mag.js/master/mag-latest.min.js"></script>
  <script src="//rawgit.com/magnumjs/mag.js/master/dist/mag.addons.0.22.min.js"></script>
</body>
</html>
 
.hide {
  display: none;
}
a {
  display: block;
}
a:after {
  content: " \bb";
}
 
/* MagJS Example - detach/reattach elements example v0.2 */
var topper = mag.create('outside', {
  controller: function(props) {
    this.li = [];
    props.data = [];
    this.willload = function() {
      props.data = [3, 2, 1];
    };
  },
  view: function(state, props) {
    state.span = props.changer % 2 ? {
      num: {
        _text: (state.status = ' ') && props.changer,
        _config: function(e, is, c) {
          c.onunload = function(context, node, xpath) {
            state.status = node.tagName + ' detached :(';
            state.li = props.data.reverse();
          };
        }
      }
    } : null;
    state.h2 = {
      _html: '<i>Welcomer</i>'
    };
    state.button = {
      _onClick: function() {
        state.h1 = props.changer = props.changer + 1 || 1;
      }
    };
  }
});
topper();
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers