Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7702021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:07:49+00:00 2026-05-31T23:07:49+00:00

In running this on index.html, I get the following error: Uncaught SyntaxError: Unexpected token

  • 0

In running this on index.html, I get the following error: “Uncaught SyntaxError: Unexpected token :”, referring to

events: {
            "click #add-friend": "showPrompt",
        },

It specifically refers to the “:” here “click #add-friend”: “showPrompt”
More context below. Any advice would be appreciated.

(function ($) {

    Friend = Backbone.Model.extend({
        // create a model to to hold friend attribute
        name: null
    });

    Friends = Backbone.Collection.extend({
        // this is our friends collection and holds out Friend models
        initialize: function(models, options) {
            this.bind("add", options.view.addFriendLi);
            // listens for "add" and calls a view function if so
        }
    });

    AppView = Backbone.View.extend({
        el: $("body"),
        initialize: function () {
            this.friends = new Friends(null, {view: this});
        // creates a new friends collection when the view is initialized
        // pass it a reference to the view to create a connection between the two
        events: {
            "click #add-friend": "showPrompt"
        },
        showPrompt: function () {
            var friend_name = prompt("Who is your friend?");
            var friend_model = new Friend({name:friend_name});
            // adds a new friend model to out Friend collection
            this.friends.add(friend_model);
        },
        addFriendLi: function (model) {
            // the parameter passed is a reference to the model that was added
            $("#friends_list").append("<li>" + model.get('name') + "</li>");
        }
    });
    var appview = new AppView;
})(jQuery);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:07:50+00:00Added an answer on May 31, 2026 at 11:07 pm

    You’ve got an extra comma at the end:

    "click #add-friend": "showPrompt" // remove the comma
    

    You are also missing a closing } at the end of the initialize method:

    initialize: function () {
        this.friends = new Friends(null, {view: this});
    }, // add a "}," here
    
    events: {
       "click #add-friend": "showPrompt"
    },
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got this jQuery pre-loading script running on a index.html page loading about 10Mb
I'm following this example to get Spring up & running: http://static.springsource.org/docs/Spring-MVC-step-by-step/part2.html What they do
Try running this in a .VBS file MsgBox(545.14-544.94) You get a neat little answer
When running this powershell command Get-ChildItem -Recurse -Include *.txt You get multiple tables in
Consider the following code: index.html <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd> <html> <head>
I have the following javascript into a index.php file: <script type=text/javascript> $('.showpics, .showpics2').live('click', function()
Let's say I have a web page ( /index.html ) that contains the following
I'm following this tutorial on running Codeigniter via the CLI. I've done everything they've
Im running this query on the same server as the web application, so SPQuery.ExpandRecurrence
I'm running this small C# test program launched from a pre-commit batch file private

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.