http://thedersen.github.com/backbone.validation/と brunch.io を統合する方法backbone.validation.js をベンダー フォルダーに入れてみました。
View = require './view'
template = require './templates/home'
User = require 'models/user'
module.exports = class HomeView extends View
id: 'home-view'
template: template
initialize: ->
Backbone.Validation.bind(this)
@user = new User
console.log @user
@user.validate()
エラー Uncaught TypeError: Object # has no method 'validate' を返します
それから私も試しました
# The application bootstrapper.
Application =
initialize: ->
HomeView = require 'views/home_view'
Router = require 'lib/router'
User = require 'models/user'
# Ideally, initialized classes should be kept in controllers & mediator.
# If you're making big webapp, here's more sophisticated skeleton
# https://github.com/paulmillr/brunch-with-chaplin
@homeView = new HomeView model: new User
# Instantiate the router
@router = new Router()
# Freeze the object
Object.freeze? this
module.exports = Application
そしてこれも
Model = require './model'
HomeView = require 'views/home_view'
module.exports = class User extends Model
defaults:
logged_in: false,
token: false
initialize: ->
new HomeView model: new User
validation:
email: {
required: true,
pattern: 'email',
msg: 'Please enter a valid email' },
name: {
required: true,
msg: "Name is required" }
Uncaught RangeError: Maximum call stack size exceeded というエラーが発生します
したがって、この問題を解決するために助けが必要なため、どのトリックも機能しませんでした。