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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:47:14+00:00 2026-06-18T02:47:14+00:00

I have a view, which holds handlebars template. that template consist of another partial

  • 0

I have a view, which holds handlebars template.
that template consist of another partial template.
that partial template holds a list of results, which i am using in different parts of my app.
anyhow, when trying to filter the results, i’d like to render only that part. meaning the backbone view should not render the whole view just the partial.
can it be done?

  • 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-18T02:47:15+00:00Added an answer on June 18, 2026 at 2:47 am

    Yes, it’s possible. The easiest way is to execute the whole template as you do when rendering the complete view, but only replace the the part you need in the view’s el.

    Something like:

    template: Handlebars.compile(templateHtml),
    
    render: function() {
      //let's say your render looks something like this
      this.$el.html(this.template(this.model.toJSON());
    },
    
    renderList: function() {
      var html = this.template(this.model.toJSON());
      var selector = "#list";
    
      //replace only the contents of the #list element
      this.$el.find(selector).replaceWith($(selector, html));
    }
    

    Depending on how dynamic your template is, you may have to call this.delegateEvents() after replacing the list for the view’s events to work correctly.

    Edit based on comments:

    To clarify, the method I propose here does execute the view’s main handlebars template again, but it doesn’t render the whole view again.

    Step by step:

    1. Execute the Handlebars template function as you do in normal render.

      var html = this.template(this.model.toJSON());
      

      The variable html now contains a string of HTML markup. Nothing has yet been rendered.

    2. Define a selector for the element, which you would like to re-render.

      var selector = "#list";
      
    3. Find the DOM element to replace. This presumes that you have already rendered the view once. Otherwise there will be no #list element within this.$el.

      this.$el.find(selector)
      
    4. Find the corresponding element in the templated html string, and replace the existing element with the new one:

      .replaceWith($(selector, html));
      

    This will only replace the #list element that’s currently on the page. Anything outside #list will not be re-rendered or touched in any way.

    The main reason I propose you do it this way instead of executing and rendering the partial template separately is that your view doesn’t need to know anything about the implementation details of the template and the templating engine. All it needs to know that there is an element #list. I believe this is a cleaner solution, and keeps your template details separate from your view logic.

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

Sidebar

Related Questions

In the partial view I have to access Session variable LoginInfo which holds a
Pretty Basic one here guys. I have a View which holds 2 textfields for
I have one view holding a list of videos(buttons which can be clicked, each
I have a custom view that holds, among other views, a RadioButton. The SingleRadioItem:
I have a view controller with an MKMapView that calls [self.mapView setRegion:region animated:YES]; which
I have an application which holds a list of documents. These documents are indexed
I have two projects, a resourcelibrary which holds a xaml file that simply has
I have a linear layout which holds inner (child) custom image view. My goal
I have a scroll view which holds a number of smaller views. I just
I have a ObservableCollection which holds records of custom type Item. I use that

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.