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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:32:48+00:00 2026-06-16T11:32:48+00:00

Imagine you have several components in your application, each having its own view. While

  • 0

Imagine you have several components in your application, each having its own view.

While the components are independent, their views may use the same identifiers for DOM elements, e.g. there is a chance that 2 or more components would have views with similar input control like:

<label for="Bid">Bid</label>
<input type="text" id="Bid" name="Bid" value="0"/>

After components are activated, their views are attached to the DOM by Boiler.ViewTemplate, and now there’s a name conflict for Bid element, causing side effects, e.g. clicking on the label works only in 1 view, and is disabled in the others.

What is the best practice to avoid such collisions? Should i use “unique” suffix/prefix for all elements in my views, like id="ComponentName_Bid"? Or there is more elegant solution?

  • 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-16T11:32:49+00:00Added an answer on June 16, 2026 at 11:32 am

    This is indeed a very good question. I too struggled with it many times. Sometime back I did an implementation of giving an auto generated unique id for every ViewTemplate instance.

    • This UID could be used from JS logic (viewmodel.js etc) by passing it from the ViewTemplate instance.
    • This could be used by view.html as well as by the component specific .css file as a tag {comp.uid} which will be replaced by a special ViewTemplate logic, just as used for ‘nls’ replacement (see line 105 at view-template.js).

    That ofcourse worked, but the complexity was too much for the developers to understand. So in a later version of BoilerplateJS I removed this functionality and let developers to manage the elementIDs manually as you have suggested above.

    I still do not know what the best approach for this.. but for the moment I believe managing it manually results in a much cleaner code.

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

Sidebar

Related Questions

Imagine you have an application with several hundreds of classes implementing dozens of high
Imagine you have a form where you switch visibility of several fields. And if
Imagine following scenario: We have a lot of parallel development going on in several
Imagine you have two views with code like the following: controller_a/a.html.erb <%= content_tag(:div) do
I have a collection of objects which have several properties in each of them.
Imagine you have a user model with a user name and several other attributes.
Let's imagine we have several type of elements, and we want to create a
I have several textbox on a page, imagine 10, 4 of these 10 have
I have a server which feeds several applications. Please imagine that I'm a user
Imagine I have a abstract FriendEvent model which has several different concrete implementations, ie.

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.