-
-
Save corydeppen/bd57eca6e1d857550e47 to your computer and use it in GitHub Desktop.
Mockjax Sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
init() { | |
this._super(...arguments); | |
let COLORS = [ | |
{ id: 1, name: 'Red' }, | |
{ id: 2, name: 'Blue' }, | |
{ id: 3, name: 'Green' } | |
]; | |
let server = new Pretender(function() { | |
this.get('/api/colors', function(request) { | |
return [ | |
200, | |
{"Content-Type": "application/json"}, | |
JSON.stringify(COLORS) | |
]; | |
}); | |
}); | |
/* | |
// Include "jquery-mockjax": "https://cdnjs.cloudflare.com/ajax/libs/jquery-mockjax/1.6.2/jquery.mockjax.js" in twiddle.json | |
$.mockjax({ | |
url: '/api/colors', | |
responseText: { | |
colors: [ | |
{ id: 1, name: 'Red' }, | |
{ id: 2, name: 'Blue' }, | |
{ id: 3, name: 'Green' } | |
] | |
} | |
}); | |
*/ | |
}, | |
model() { | |
return $.getJSON('/api/colors'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName:'Ember Twiddle' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.4.8", | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.2.0", | |
"ember-data": "2.2.0", | |
"ember-template-compiler": "2.2.0", | |
"fake-xml-http-request": "https://rawgit.com/pretenderjs/FakeXMLHttpRequest/master/fake_xml_http_request.js", | |
"route-recognizer": "https://rawgit.com/tildeio/route-recognizer/master/dist/route-recognizer.js", | |
"pretender": "https://rawgit.com/pretenderjs/pretender/master/pretender.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment