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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:50:07+00:00 2026-05-24T19:50:07+00:00

Imagine a list with some items. Each item is a movie and includes: the

  • 0

Imagine a list with some items.
Each item is a movie and includes:

  • the title
  • a ranking with stars (1-5)
  • add to my list button
  • a textbox that you might leave a comment

How might be done:

  • A) The item will listen for the buttonClicked event and then will call a method on the model:

    onClick: function(event){
       this.model.addToMyList();
    }
    

    there is no need to specify the movieId because the “model” is for this item. In the other cases the model is for all the items.

  • B The list will listen for an item to dispatch the buttonClicked event, gets data from the event and will call a method on a model:

    model.addToMyList(movieId)
    
  • C The list will listen for an item to dispatch the buttonClicked event, this event will carry on the index(that is not the id of the movie) of the item, then finds the movieId using the index on the list and will call a method on a model:

    model.addToMyList(movieId)
    
  • 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-05-24T19:50:07+00:00Added an answer on May 24, 2026 at 7:50 pm

    You don’t mention any languages so I’m going to give a language neutral response.

    Don’t recommend C: Identifying an item by the index in a list might seem an easy option but any extension functionality or maintainability could get messy later (suddenly ordering a list, having users filter the list etc).

    With maintainability in mind (not pre-emptive design but design that’ll be more accommodating to changes), it’s best for the event handler to be able to identify what’s being handled. That way, you could modify the handler that will apply for all items.

    With B: I’d more reserve that for a collection that changes, with the intention that controls/components are listening for a collection change (such as INotifyCollectionChangedin .net). So it’s a difficult thing to say not knowing whether there’s specific actions you want to do with this collection but it wouldn’t be my first choice unless the collection (as a data model) change determines other aspects.

    So with the above in mind, (this will sound like an A-B hybrid but its a commonly used solution): new items created are signed up to an event handler (just code one event handler), and pass in either the reference to the item-row itself or an identifier. So, if its possible, you’d be looking at:

    onClick: function(MyEvent e)
    {
       this.model.addToMyList(e); //or this.model.addToMyList(e.ID)
    }
    

    So you have multiple items signing up for the same event, one event handler to maintain and the ability to preserver that handling should your list be changed through filters, sorting etc.

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

Sidebar

Related Questions

Imagine a simple unsorted list with some <li> items. Now, I have defined the
Imagine the typical type of application where you have a list of items with
Let's imagine that I have list of files at host1 find /path/to -name *.jpg
Here's the problem: I have a list of items on a page, each with
Imagine you have a list of some objects. These objects are instances of various
Imagine a table view listing some recipes. Each time the user taps on a
Imagine that I want to loop over a list of jQuery objects, and for
Using this Java code: // create the items list List<Item> items = new ArrayList<Item>();
Imagine that you need to write some Javascript that simply changes a set of
Imagine a doube list like the follow List<double> lstDouble=new List<double>{4,6,2,7,1,1}; So what i want

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.