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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:56:18+00:00 2026-05-23T04:56:18+00:00

In script#, I have the following: jQuery.Select(#someId).Trigger(item-added, new object[]{ball} ); This compiles into the

  • 0

In script#, I have the following:

jQuery.Select("#someId").Trigger("item-added", new object[]{"ball"} ); 

This compiles into the following Javascript:

$('#someId').trigger('item-added', [ 'ball' ]);

The above code works fine. The problem comes in declaring an event handler that can receive the argument array.

In order for my handler to receive the argument array, it would have to have a signature as such:

public void OnItemAdded(jQueryEvent jqe, Object[] args)

However, the only type available is:

public delegate void jQueryEventHandler(jQueryEvent e)

And as such, when the handler is called, the args are nowhere to be found.

I’ve read about the other methods of passing arguments to event handlers on the jQuery api docs ( http://api.jquery.com/trigger ) and they don’t seem to be possible in script#.

  • 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-23T04:56:19+00:00Added an answer on May 23, 2026 at 4:56 am

    Adding to DuckMaestro’s suggestion –

    The sources for Script.jQuery are on github … they’re there so people can change it, not be blocked, and not have to resort to things like InvokeMethod, Script.Literal and other such sub-optimal workarounds.

    The reason the signature is not like that to begin with is every event handler shouldn’t need to define extra parameters in its signature when not needed.

    Option 1 –

    Create a different delegate signature – like jQueryEventHandler. And then create overloads of Bind, and Trigger that use your new signature. Its not hard, esp. if you look at the existing implementation source as a reference.

    Option 2 –

    Use the other pattern suggested by examples at http://api.jquery.com/trigger.

    var event = jQuery.Event("item-added");
    event.item = "ball";
    $("#someid").trigger(event);
    

    Specifically add properties to jQueryEvent and then create the derived class where you trigger the event, set properties on it for your specific scenarios. And then in the event handler cast the jQueryEvent back to the specific type.

    The nice thing about this is it is consistent with the DOM… in terms of what you’d do with document.createEvent, and dispatchEvent. As such I prefer this option, besides the fact that it doesn’t need overloads of bind/trigger for every specific scenario.

    The one thing you’ll run into right now is jQueryEvent itself is sealed right now, but I am happy to make that unsealed to support these scenarios (be sure to log a bug on github so it can be tracked). In the mean-time to be unblocked, you have the sources to make it unsealed on your end.

    If you really don’t want to get into rebuilding Script.jQuery, a temporary workaround (until you have a build where you can start deriving from) is the following:

    jQueryEvent e = jQuery.Event("item-added");
    Script.Literal("{0}.item = {1}", e, "ball");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following string expression in a PowerShell script: select count(*) cnt from
I have my front end script which has the following jQuery code: $.get(/backend/post.php, {
i have the following script <select id=select1> <option value=1>1day</option> <option value=2>2day</option> <option value=3>3day</option> </select>
I have the following script at the end of my page: <script type=text/javascript> jQuery.noConflict();
I have the following test ASPX page: <head runat=server> <title></title> <script src=js/jquery-1.2.6.min.js type=text/javascript></script> <script
Fairly new to asp.net Mvc and jquery. Have the following code working fine, but
I have the following script. It replaces all instances of @lookFor with @replaceWith in
I have the following script, where the first and third document.writeline are static and
i have the following script import getopt, sys opts, args = getopt.getopt(sys.argv[1:], h:s) for
I have the following shell script registered in my Login Items preferences but it

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.