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 8265721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:54:14+00:00 2026-06-08T04:54:14+00:00

I am trying to set up a show page for a Post that is

  • 0

I am trying to set up a show page for a Post that is accessed via a link:

<a class="post-link button" href="#">details</a>

When the post item is rendered, it is given an href like so:

this.$('a').attr('href', this.postUrl());

...

postUrl: function() {
  return "#posts/" + this.model.get('id');
}

When the fields are rendered, the links show up as:

http://[path_to_app]/#posts/[whatever_id]

When I click the link, then it should hit this router:

routes: {
  ''          : 'index',
  'new'       : 'newPost',
  "posts/:id" : 'show'
}

But I get this error, and it never goes in to the show function at all:

Uncaught Error: Syntax error, unrecognized expression: /1 jquery.js:4268
  Sizzle.errorjquery.js:4268
  Sizzle.filterjquery.js:4254
  Sizzlejquery.js:4044
  Sizzlejquery.js:5176
  jQuery.fn.extend.findjquery.js:5432
  jQuery.fn.jQuery.initjquery.js:188
  jQueryjquery.js:28
  hashchangetabs.js:9
  jQuery.event.dispatchjquery.js:3333
  jQuery.event.add.elemData.handle.eventHandle

When I change the link to be “#post/” + id and the route to “post/:id”, then this error does not occur.

I am in the process of learning Backbone, and could really use a hand here. Also of note: my routes root to posts#index action.

EDIT (more relevant code):

# Model
[APP].Models.Post = Backbone.Model.extend({
  urlRoot: '/posts'
});

#Router
[APP].Routers.Posts = Support.SwappingRouter.extend({
  initialize: function(options) {
    this.el = $('#posts');
    this.collection = options.collection;
  },

  routes: {
    ''          : 'index',
    'new'       : 'newPost',
    "posts/:id" : 'show'
  },

  index: function() {
    var view = new [APP].Views.PostsIndex({ collection: this.collection });
    this.swap(view);
  },

  newPost: function() {
    var view = new [APP].Views.PostsNew({ collection: this.collection });
    this.swap(view);
  },

  show: function(postId) {
    var post = this.collection.get(postId);
    var postsRouter = this;
    post.fetch({
      success: function() {
        var view = new [APP].Views.PostShow({ model: post });
        postsRouter.swap(view);
      }
    });
  }
});

#Post Item View
[APP].Views.PostItem = Backbone.View.extend({
  tagName: 'tr',

  initialize: function() {
    _.bindAll(this, 'render');
  },

  render: function () {
    this.$el.attr('id', 'post_' + this.model.id);
    this.$el.html(JST['posts/item']({ post: this.model }));
    this.renderFormContents();
    return this;
  },

  renderFormContents: function() {
    ...
    this.$('a').attr('href', this.postUrl());
  },

  postUrl: function() {
    return "#posts/" + this.model.get('id');
  }
});
  • 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-06-08T04:54:16+00:00Added an answer on June 8, 2026 at 4:54 am

    Somewhere, someway, somehow, this issue was being caused by files not being loaded in a certain order. I wish I could be more specific, but I was not loading in backbone.min.js in the right place.

    I was able to have some functionality, though, because I had included an old backbone partial file that I tried to customize, broken, and thought was deleted.

    Really, really stupid mistake that I could not figure out for a little while. Thanks for all of your help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to set a flag to show or hide a page element,
I'm trying to set up an apache server to show a map for FlightGear
I am trying to load/show completely different set of values in a combobox(this one
I'm trying to use the show and hide to display a different set of
I am trying to show a ListFragment. I think I have everything set up
Trying to set a flag in the post to allow processing or not. The
Here is the page I am affecting: http://www.careerchoiceswithlaura.com/blog/ Inspecting the elements will show that
I'm trying to set up some semistatic page in a rails 3 app I've
I am trying to set up some semistatic page in a rails 3 app,
I saw a similar post that was trying to do this same thing with

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.