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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:48:58+00:00 2026-06-03T07:48:58+00:00

suppose there is a bookList View (with books as it’s model) and some book

  • 0

suppose there is a bookList View (with books as it’s model) and some book view (with book as it’s model)

If i want to run a function in every book view. there are a least two ways:

  1. maintain an array which contain all book views in bookList view, than run the function directly

  2. trigger a custom event on every book model in the books model to make the view run the function.

which one is better?

  • 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-03T07:48:59+00:00Added an answer on June 3, 2026 at 7:48 am

    I really think you should consider a bit more things about your application and you will be guided to the decision by the natural flow of the concept of your application.

    So according your methods :

    Maintaining an array with views

    If you don’t have plenty of those bookView, it can be a solution. In fact, the question you should ask yourself here is do you really need this array only for that function, or could be used for something else.

    Trigger a custom event on every book model

    This will add to every bookView some identical event listeners and callbacks ( the function itself ). Which will require every bookView the memory share in your browser, for the same information.

    I’m also thinking of a third method :

    Trigger one custom event in your bookList View, which is listened by your Book views

    So you could manage to do this and set an argument at the trigger with the function you want, so basically your code in your book View will be something like :

    var cb = function(theFn) {
        theFn.apply(this); // here we are setting theFn this to this view
    }
    
    bookList.on('doThisFunction', cb, this);
    

    When you trigger you can do something like

    theFn = function() {
          this.render();
    }
    bookList.trigger('doThisFunction', theFn);
    

    Be ware that when you no longer need the bookView you should turn off the eventlistener : bookList.off('doThisFunction', cb) from your book View , because you will have a garbage in your bookList event aggregator.

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

Sidebar

Related Questions

Suppose there is a frame with some image.I want to display only those parts
Suppose there is a some string: std::string some_string = some_string; And I want to
Suppose There are some activity. I want to start another activity from the main
Suppose there are only two type of model objects. Tag Article Article can have
Suppose there are two singly linked lists both of which intersect at some point
Suppose there are two classes: class A(models.Model): … class B(models.Model): a = models.ForeignKey(A) …
Suppose there is a business function you need to implement, which sets some kind
Suppose there are two lists a = {a1, a2, a3} and b = {b1,
Suppose there is an image_url column in database. I want the user to choose
Suppose there is a System A which gives some output. This output is used

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.