<html>
<head>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="//builds.emberjs.com/tags/v1.11.3/ember-template-compiler.js"></script>
<script src="//builds.emberjs.com/tags/v1.11.3/ember.debug.js"></script>
<!--
<script src="//builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v2.0.0.js"></script>
<script src="//builds.emberjs.com/tags/v1.9.0/ember.js"></script>
-->
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script type="text/x-handlebars" data-template-name="application">
<div style="border:1px solid #aaa; background-color:#eee">
To repeat the bug, click on the link ("go to private link with query params") and after click on login. Nothing happens, appears an error on the transition.retry(). If you wish, you can check it again, clicking on login other time, and the application was logged with a sample data.
</div>
<div>
{{outlet}}
</div>
</script>
<script type="text/x-handlebars" data-template-name="login">
<div>
{{#link-to "data" 1 (query-params q="pepinillos")}}Go to a private link with query params{{/link-to}}
</div>
<button {{action "login"}}>Login</button>
</script>
<script type="text/x-handlebars" data-template-name="private">
<div>{{model.name}}</div>
{{outlet}}
<button {{action "logout"}}>Loggout</button>
</script>
<script type="text/x-handlebars" data-template-name="data">
<div>Model: (Query: {{q}})</div>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="data/index">
<div>Index</div>
<div>{{model.name}}</div>
<div>{{substring}}</div>
</script>
</body>
</html>
var logged=false;
var pending_transition=null;
App=Ember.Application.create({});
App.P = Em.Object.extend();
App.P.reopenClass({
find: function(id) {
if (id) {
return App.FIXTURES.findBy('id', id);
} else {
return App.FIXTURES;
}
}
});
App.FIXTURES=[
{
name:"Testing 1",
id: "1",
},
{
name: "Testing 433",
id: "2"
},
{
name: "PEPITO",
id: "0"
}
];
App.Router.map(function (){
this.resource('private', {path: '/'}, function (){
this.resource('data', {path: '/data/:p_id'}, function (){
this.route('index');
});
});
this.resource('login', {path: '/login'});
});
App.LoginController = Ember.Controller.extend({
actions: {
login: function (){
logged=true;
if (pending_transition!=null){
var old_transition=pending_transition;
pending_transition=null;
try{
old_transition.retry();
} catch (e){
console.log("catch");
this.transitionToRoute('data', 0);
}
} else {
this.transitionToRoute('data', 0);
}
}
}
});
App.PrivateRoute = Ember.Route.extend({
beforeModel: function(transition) {
if (logged===false) {
pending_transition=transition;
this.transitionTo('login');
}
}
});
App.PrivateController = Ember.Controller.extend({
actions:{ logout: function (){
logged=false;
this.transitionToRoute('login');
}
}
});
App.DataRoute= Ember.Route.extend({
queryParams: {
q: { refreshModel:true }
},
model: function (params){
return App.P.find(params.p_id);
}
});
App.DataController = Ember.Controller.extend({
queryParams: ["q"],
q:null,
actions: {}
});
App.DataIndexController = Ember.Controller.extend({
substring: function (){
return "Hello WORLDING";
}.property(),
});
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |