javascript - Using razor syntax in Ember App.js ajax call -
i trying write first ember
app , not sure @ i'm doing. doing in asp mvc 4 project , want able click "agent" menu tab, , have ember grab relevant information agent
controller.
when think have set properly, because when click on "agent" menu item following error:
"error while loading route"
again, first attempt @ ember, assume means ajax call being attempted, i've routed razor syntax not being translated properly.
app = ember.application.create(); app.store = ds.store.extend({ adapter: 'ds.fixtureadapter' }); app.router.map(function () { this.resource('home', { path: "/index" }); this.resource('agents', { path: "/agents" }); this.resource('topics', function() { this.resource('topic', {path: '/topic/:topic_id'}) }); this.resource('contacts', { path: "/contacts" }); }); app.agentsroute = ember.route.extend({ model: function () { return app.store.all(); } }) app.store.reopenclass({ all: function () { return $.ajax({ type: 'get', data: {id: '1'}, url: '@url.action("getagentdata", "agent")', sucess: function (data) { return data; } }); } });
edit
per request here handlebars code layout.cshtml
page.
<nav> <script type="text/x-handlebars"> <div class="navbar"> <div class="navbar-inner"> <ul id="menu"> <li>{{#linkto 'home'}}home{{/linkto}}</li> <li>{{#linkto 'agents'}}agents{{/linkto}}</li> <li>{{#linkto 'topics'}}about{{/linkto}}</li> <li>{{#linkto 'contacts'}}contact{{/linkto}}</li> </ul> </div> </div> {{outlet}} </script> </nav>
Comments
Post a Comment