Hi there,
I am having problems with posting data to URL , though I have checked the URL in Soap UI and it worked ,but when I try to do the same using ember its not working .So ,please help. My code in app.js goes here ,
var App = Ember.Application.create();
App.Router.map(function() {
this.resource('about');
this.resource('persons', function() {
this.resource('data', { path: ':person_id' });
});
});
App.Store = DS.Store.extend({
revision: 12,
adapter: DS.RESTAdapter.extend({
url: 'http://portNum/pathToSendJsonData'
})
});
App.PersonsRoute = Ember.Route.extend({
model: function(){
return App.Person.find();
}
});
App.Person = DS.Model.extend({
name: DS.attr('string'),
file: DS.attr('string')
});
App.DataController = Ember.ObjectController.extend({
isEditing: false,
edit: function() {
this.set('isEditing', true);
},
doneEditing: function() {
this.set('isEditing', false);
var store = this.get('store');
store.createRecord('person', {
name: 'Rails is Omakase',
file: 'Lorem ipsum'
});
// this.get('store').commit();
// this.get('Person').save();
}
});
My code in index.html goes here
<html>
<head>
<meta charset="utf-8">
<title>Ember Starter Kit</title>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css">
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
</head>
<body>
<script type="text/x-handlebars" id="blogger">
<h2>Here in Blogger</h2>
</script>
<script type="text/x-handlebars">
<div class="navbar">
<div class="navbar-inner">
<ul class="nav">
<li>{{#link-to 'persons'}}Person{{/link-to}}</li>
<li>{{#link-to 'about'}}About{{/link-to}}</li>
</ul>
</div>
</div>
{{outlet}}
</script>
<script type="text/x-handlebars" id="persons">
<div class="container-fluid">
<div class="row-fluid">
<div class="span3">
<table class='table'>
<thead>
<tr><th>Recent Posts </th></tr>
</thead>
{{#each model}}
<tr><td>
{{#link-to 'data' this}} {{name}}{{/link-to}}
{{file}}
</td></tr>
{{/each}}
</table>
</div>
<div class="span9">
{{outlet}}
</div>
</div>
</div>
</script>
<script type="text/x-handlebars" id="data">
{{#if isEditing}}
{{partial 'data/edit'}}
<button {{action 'doneEditing'}}>Done</button>
{{else}}
<button {{action 'edit'}}>Edit</button>
{{/if}}
<div class='below-the-fold'>
<p></p>
<p>{{name}}</p>
<p>{{file}}</p>
</div>
</script>
<script type="text/x-handlebars" id="data/_edit">
<p>{{view Ember.TextField valueBinding = 'name'}}</p>
<p>{{view Ember.TextField valueBinding = 'file'}}</p>
</script>
<script type="text/x-handlebars" id="posts/index">
<p class="text-warning">Please select a post</p>
</script>
<script type="text/x-handlebars" id="about">
<p>in about route</p>
</script>
<script src="js/libs/jquery-1.10.2.js"></script>
<script src="js/libs/handlebars-1.1.2.js"></script>
<script src="js/libs/ember-1.5.1.js"></script>
<script src="js/bower_components/ember-data/ember-data.js"></script>
<script src="js/app.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/showdown/0.3.1/showdown.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.1.0/moment.min.js"></script>
<!-- to activate the test runner, add the "?test" query string parameter -->
<script src="tests/runner.js"></script>
</body>
</html>
The Json format to send data is :
{
"persons": [{
"id": 61,
"name": "aaa",
"file": "File_a"
},
{
"id": 62,
"name": "bbb",
"file": "File_b"
}]
}
So,this is it,Please help thanks in advance