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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:47:21+00:00 2026-06-15T16:47:21+00:00

UPDATE (RELEVANT DETAIL): This composite view is within a collection of composite views. How

  • 0

UPDATE (RELEVANT DETAIL): This composite view is within a collection of composite views.

How can I construct the following HTML using a Backbone.Marionette composite view?

    <optgroup label="Group 1">
        <option>Item 1</option>
        <option>Item 2</option>
        <option>Item 3</option>
    </optgroup>
    <optgroup label="Group 2">
        <option>Item 4</option>
        <option>Item 5</option>
        <option>Item 6</option>
    </optgroup>

Since I want to avoid the <div> wrapper, I will have to specify <optgroup> as the tagName.

view = Backbone.Marionette.CompositeView.extend({
    collection: some_collection,
    itemView: some_itemview,
    template: '#some_template', <!-- What goes inside the template? -->
    itemViewContainer: 'optgroup',
    tagName:'optgroup', <!--specify to avoid the default div-->

    <!-- What should I specify in order to pass label="Group1" to the optgroup tag-->
});
  • 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-15T16:47:22+00:00Added an answer on June 15, 2026 at 4:47 pm

    Don’t use a CompositeView for this. You don’t need a wrapper template since the wrapper in this case is only the <optgroup> tag.

    Use a CollectionView instead, which doesn’t render a wrapper template.

    For the group #, use the onRender method

    
    view = Backbone.Marionette.CollectionView.extend({
        collection: some_collection,
        itemView: some_itemview,
        tagName:'optgroup',
    
        onRender: function(){
          this.$el.attr("label", "Group 1");
        }
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application which you can view by clicking on this link application
I want to call a webservice using Zend_Soap_Client. This is the relevant code: $params
I am trying to implement a simple observer pattern to update widgets with relevant
What is the most relevant and best way to update data on an iOS
Update: I reported this as a bug to Apple and they fixed it! All
UPDATE: I've been playing around with this more, and it seems like tmux's clear-history
Update : This is no longer an issue from C# 6, which has introduced
I am using the following code in order to add images to an existing
Update: This issue is caused by bad memory usage, see solution at the bottom.
I'm faced with a situation that I think can only be solved by using

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.