Im using spinejs, coffeescript and asp.net mvc. Heres the code for spine controller class:
class Schedules extends Spine.Controller
constructor: -> super alert "Created"
events:
"click": "click"
click: ->
alert("Was clicked")
In a asp.net mvc view I have all js included and the following code to init controller:
$(document开发者_运维百科).ready(function () {
var sched = new Schedules({
el: $("#myId")
});
});
But I see the following error: Uncaught ReferenceError: Schedules is not defined.
UPDATE: Now I it doesn`t do anything and no error is provided. I cant see my alert message. But it should show alert message after controller creation. In controller file:
window.SchedulesApp = {}
class SchedulesApp.Schedules extends Spine.Controller
//futher controller code
In the asp.net mvc View I have the following:
<script type="text/javascript">
$(document).ready(function () {
var controller = new SchedulesApp.Schedules({});
You should consider using namespaces:
window.SchedulesApp = {}
class SchedulesApp.Schedules extends Spine.Controller
constructor: ->
super
alert "Created"
events:
"click": "click"
click: ->
alert("Was clicked")
EDIT
So, you have another problem and that is how you call super
which is causing everything afterwards to be wrapped into a parameter to super
.
I have fixed it with the CS output with jsFiddle and edited the CS in this answer.
Hope this helps!
精彩评论