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

The Archive Base Latest Questions

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

Instead of selecting an item first and then using a button to perform some

  • 0

Instead of selecting an item first and then using a button to perform some action on the selected item I would prefer for the user to perform one click.

It seems to work but I have concerns that the event on the button must occur after the event on the carpool_event. This just doesn’t seem right. Is there a better way to handle this? Thanks!

in my HTML

<template name="carpool_list">
  <h1>Carpool</h1>
  {{#each carpool_events}}
  <ul>
    {{> carpool_event}}
  </ul>
  {{else}}
    No events yet.
  {{/each}}
</template>

<template name="carpool_event">
  <div class="carpool_event">
    <span class="localDate">{{localDate}}</span>
    <span class="owner">{{owner}}</span>
    {{#if currentUser}}
      <span><input type="button" class="takeEvent" value="Take Event"/></span>
    {{/if}}
  </div>
</template>

corresponding js

Template.carpool_event.events({
    'click': function () {
      Session.set("selected_carpool_event", this._id);
    }
  });

Template.carpool_list.events({
    /**
     * Take Event Handler
     */
    'click .takeEvent': function () {
      console.log("Take event:"+Session.get("selected_carpool_event"));
    }
});
  • 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:42:53+00:00Added an answer on June 18, 2026 at 2:42 am

    You could try this:

    Template.carpool_event.events({
    "click": function () {
          Session.set("selected_carpool_event", this._id);
          if($(event.target).attr("class") == "takeEvent" && Meteor.userId) {
             console.log("Take event:"+this._id);
          }
        }
    });
    

    or if you want both clicks for some other reason or you can avoid having capturing the first click you could target the button directly, this._id should work on the button too (you can assign a handler to the same template carpool_event for a button anywhere inside the template)

    Template.carpool_event.events({
        /**
         * Take Event Handler
         */
        "click .takeEvent": function () {
           Session.set("selected_carpool_event", this._id);
           if(Meteor.userId) {
               console.log("Take event:"+this._id);
           }
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Instead of selecting files manually when using git add , is there a way
I want to change a button color in my app by selecting color. Instead
Instead of stepping when the user clicks somewhere on the qslider I want to
Instead of having nested callbacks in JS, I would like to fire and listen
I am using Listview,the View selected is largeicon mode. The problem i am facing
I'm selecting a ListItem as I add it to a ListItemCollection. Then I use
I'm having some trouble selecting a tab programmatically. My tabs are loading inside a
I have a listview and a button next to it that uses the selected
I have a ListView containing some ListViewItems. By default, selecting items makes their background
I have a listbox that, when an item is selected, invokes a method 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.