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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:54:47+00:00 2026-05-22T15:54:47+00:00

I am tinkering with this code: var items; function getMessage(index) { if (index ==

  • 0

I am tinkering with this code:

var items;

function getMessage(index) {
    if (index == items.size()) return;
    var item = items.eq(index);
    $.get('/message/' + index,
        function(response) {
            item.html(response);
            $("ul").trigger('updated', index);
        }
    );
}

$(document).ready(function(){
    items = $(".message");

    $("ul").bind('updated',
        function(event, i) {
            getMessage(i + 1);
        }
    );
    getMessage(0);

});

And this html:

<ul>
    <li class="message"></li>
    <li class="message"></li>
    <li class="message"></li>
</ul>

According to the documentation of the jQuery .trigger() function,

"A single [extra] parameter can be passed without using an array."

But in the above code, the function listening on the "update" event never gets the parameter "index" (passed in line 9), unless I enclose it in brackets like this:

$("ul").trigger('updated', [index]);

I am not even sure if this is something related specifically to jQuery. Could you help me understand what is happening?

  • 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-22T15:54:47+00:00Added an answer on May 22, 2026 at 3:54 pm

    +1 Nash

    Doesn’t looks like if jQuery isn’t handling the case of one parameter passed without an Array. Verified both from the API & the latest source.

    The only exception i m guessing is that the value is received by a variable called data. And it goes like this:

    data ? jQuery.makeArray( data ) : [];
    

    Now in JavaScript, if the data variable has value 0 (number), the if check returns false. So, when the first time you would run it, it will not execute makeArray().

    Again, this is only a think-aloud guess. Please don’t get misguided, if that is not the case.

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

Sidebar

Related Questions

INITIAL NOTE: This is just for a personal tinkering project; I'm not writing enterprise
I was just tinkering around with calling GetPrivateProfileString and GetPrivateProfileSection in kernel32 from .NET
I have been tinkering with BSP trees for a while now and am also
I'm tinkering with Silverlight 2.0. I have some images, which I currently have a
I'm currently tinkering at an OpenBSD system with a view to building myself a
I've been tinkering with small functions on my own time, trying to find ways
I've been tinkering with Yahoo Pipes and the Amazon Product Advertising API (formerly ECS)
I am looking to do some tinkering with openGL and Python and haven't been
After making a few modifications to a rails app I am tinkering on, railroad
Returning to WinForms in VS2008 after a long time.. Tinkering with a OOD problem

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.