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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:19:02+00:00 2026-06-15T17:19:02+00:00

I have a template with a list <ul> that has 2 <li> with links

  • 0

I have a template with a list <ul> that has 2 <li> with links <a id='variable_id'> with different ids. I’ve bind the events to this 2 ids iniciais and palavras. The thing is, when i click for an example the iniciais link, i remove it from the <ul> and create a new link with the id='palavras'. The problem is, this new link doesn’t have the events binded to it, even though the event is on the events hash. How can i do something like jQuery live or on methods on a Backbone View subelement?

var MyView = Backbone.View.extend({
  el: '#campos',
  initialize: function() {
  },

Notice how i have the events binded to the 2 kinds of links.

  events: {
    'click #palavras': 'mudar_para_consulta_palavras',
    'click #iniciais': 'mudar_para_consulta_iniciais'
  },

In this method, i remove the list item from the list, and insert some new content with the new id.

  mudar_para_consulta_palavras: function() {
    $('#campo_consulta').val('');
    $('#campo_consulta').attr('placeholder', 'Digite palavras inteiras');
    $("#campo_consulta").attr('tipo', 'chave');
    $('#palavras').parent().remove();
    $("<li><a id='#iniciais'>Consultar por Iniciais</a></li>").insertBefore('.divider');
  },

Same thing for this other method, only changes the id definition.

  mudar_para_consulta_iniciais: function() {
    $('#campo_consulta').val('');
    $('#campo_consulta').attr('placeholder', 'Digite inicio de palavras');
    $("#campo_consulta").attr('tipo', 'iniciais');
    $('#iniciais').parent().remove();
    $("<li><a id='#palavras'>Consultar por palavras</a></li>").insertBefore('.divider');
  }
});
return MyView;
});
  • 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-15T17:19:03+00:00Added an answer on June 15, 2026 at 5:19 pm

    I think you simply have small typo in the markup you insert into the DOM:

    $("<li><a id='#iniciais'>Consultar por Iniciais</a></li>")
    

    and

    $("<li><a id='#palavras'>Consultar por palavras</a></li>")
    

    Should not have the # character in the id attribute.

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

Sidebar

Related Questions

I have a base.html template that contains a list of links. Example: <div id=sidebar1>
I have code that looks like this: template<class T> class list { public: class
I have a Python list that I'm supplying to the template: {'error_name':'Please enter a
I have a view that renders a list elements using the following template :
I have a custom iterator template class that wraps up a std::list iterator. In
For a list box in WPF I have this template: <ControlTemplate x:Key=ListBoxItemControlTemplate1 TargetType={x:Type ListBoxItem}>
I have a long list of links that I spit out using the below
I am having trouble with a template that has to check 3 different nodes
Hey I have a list that has values in it, I want to print
I have an order entry form that has a ListBox with a list of

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.