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

  • Home
  • SEARCH
  • 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

With this code vozhus very much in it for a long time tinkering that
I get this error message: Parse error: syntax error, unexpected $end in C:\Users\Stacky\Desktop\xampp\htdocs\wweff\stackhelp.php on
Been tinkering with some code regarding setting the visibility of a drop down based
I've been tinkering with some code in a effort to understand OOP using c.
After several hours of tinkering I cannot seem to figure this out. I have
I'm tinkering with some code and I realized something I never knew. A normal
I'm a relatively new java programmer and I've been tinkering around with this program
I'm making this function that takes a string input, converts it to an int,
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

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.