Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

: ReferenceError: users is not defined #143

Open
Gajendrasinh opened this issue Apr 14, 2016 · 1 comment
Open

: ReferenceError: users is not defined #143

Gajendrasinh opened this issue Apr 14, 2016 · 1 comment

Comments

@Gajendrasinh
Copy link

I am new in backbone i am try to implement your code for demo but i getting below error can you please tell me where i am doing mistake.

here i am attached code
Error : ReferenceError: users is not defined
_.each(users, function(user){

<title>Backbon JS</title>

User Manager


<script type="text/template" id="user-list-template"> ``` <% _.each(users, function(user){ %> <% }); %>
firstname lastname age
<%= user.get('firstname') %> <%= user.get('lastname') %> <%= user.get('age') %>
``` </script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.3.3/backbone-min.js"></script> <script type="text/javascript"> var Users = Backbone.Collection.extend({ url : 'http://backbone-beginner.herokuapp.com/users' }); var UserList = Backbone.View.extend({ el: '.page', render: function(){ var that = this; var users = new Users(); users.fetch({ success:function(users){ var template = _.template($('#user-list-template').html(), {users: users.model}); that.$el.html(template); } }) } }); var Router = Backbone.Router.extend({ routes: { "": "home" } }); var userList = new UserList(); var router = new Router(); router.on('route:home', function() { userList.render(); console.log("We have loaded the home page"); }); Backbone.history.start(); </script>
@artemrogov
Copy link

Привет, у тебя из ошибки видно: что ты не инициализировал параметр -user. Поэтому он пишет тебе я не могу найти - user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants