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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:08:00+00:00 2026-06-15T03:08:00+00:00

Inorder to speed up the app I am trying to use a delegate function

  • 0

Inorder to speed up the app I am trying to use a delegate function instead of the click function… but due to some reasons I am unable to even enter the function….

Any help??

Here is the code:

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1"> 
            <link rel="stylesheet" href="css/checkbox.css"/>
            <link rel="stylesheet" href="css/jquery.mobile-1.1.1.css" />

        <title>Subscribe</title>
        <script src="scripts/jquery-1.8.2.min.js"></script>
        <script src="scripts/jquery.mobile-1.2.0.min.js"></script>

        <script type="text/javascript">
            $(document).ready(function() {

**Want to use Delegate instead of Click**
                   $('#selectAllTechAreas').click(function(){
                    //alert('aaa');
                      $('.techAreasCheckBox').attr('checked', true);
                    }); // Tech Areas Select All click function

                    $('#selectAllAssetTypes').tap(function(event){
                            $('.assetTypeCheckBox').attr('checked', true);
                    }); // Asset Types Select All click function
                    $('#clearAllSelections').click(function(){
                        $('.assetTypeCheckBox').attr('checked', false);
                        $('.techAreasCheckBox').attr('checked', false);
                    });
            }); // document
        </script>

    </head>

    <body>

        <div data-role="content" class="contentGrayBg">
            <div id="categoriesTable">
                </table>
                <br>

                <div class="container">
                        <div class="floatLeft">
                                <table id="technologyAreas">
                                    <tr>
                                        <td>
                                            <fieldset id="techAreasCB" data-role="controlgroup">
                                            <legend style="font-style: bold; font-size:16px">Technology Areas:</legend>
                                                <table>
                                                    <tr>
                                                        <td><input type="checkbox" data-mini="true" name="checkbox1" id="checkbox1" class="case techAreasCheckBox" /></td>
                                                        <td style="padding-left: 40px">SAP</td>
                                                    </tr>
                                                    <tr>
                                                        <td><input type="checkbox" data-mini="true" name="checkbox2" id="checkbox2" class="case techAreasCheckBox" /></td>
                                                        <td style="padding-left: 40px">Oracle</td>
                                                    </tr>

                                                    <tr>
                                                        <td><!-- <input type="checkbox" id="selectAllTechAreas"/> --></td>
                                                        <td >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label id="selectAllTechAreas" style="color: orange; padding-left: 10px"><b>Select All</b></label></td>
                                                    </tr>
                                                </table>        
                                            </fieldset>
                                        </td>
                                    </tr>
                                </table>
                        </div>  <!-- Div Class Float Left -->


                </div>
            </div>
        </div> 

    </body>
    </html>

Thanks,
Ankit.

  • 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-15T03:08:01+00:00Added an answer on June 15, 2026 at 3:08 am

    For purposes of generality I am going to assume you want to delegate to the document:

    $(document).on('click','#selectAllTechAreas',function(){
            $('.techAreasCheckBox').attr('checked', true);
            // ...
    });
    

    Generally, the pattern followed is:

    $(document).on('click','#selectAllTechAreas',function(){
    -----------    -------  -------------------  -----------
         |            |               |                |
    element you     event  selector that specifies  your handler
    want to          type    which elements to
    delegate to             fire the handler for
    

    To be clear here, I am not advocating that you delegate your handler to the document, or even to any ancestor, since your target is a single element (particularly since you seem to not be entirely clear on the utility of delegation). I recommend reading this article to get a better handle on the subject.

    To elaborate on the motivation behind delegation, and why it is pointless to delegate the event for a single element, consider the following:

    <ul id="parent-list">
      <li id="post-1">Item 1</li>
      <li id="post-2">Item 2</li>
      <li id="post-3">Item 3</li>
      <li id="post-4">Item 4</li>
      <li id="post-5">Item 5</li>
      <li id="post-6">Item 6</li>
    </ul>
    

    Say I wanted to attach a click event for every list item. I would end up having to attach 6 event handlers like so:

    $('li').click(function(){
        alert('clicked!');
    });
    

    Behind the scenes, jQuery is iterating over each li and attaching that event handler for it. It would be nice if there was a less wasteful way to do this…

    This is where delegation comes in. I can attach just one handler to the ul, which checks whether the target of the event matches the selector li, before firing the event handler:

    $('ul').on("click","li",function(){
        alert('clicked!');
    });
    

    This is more efficient than maintaining 6 separate identical event handlers.

    Now let us look at your case. In your case, you want to attach an event handler to #post-1. The most efficient way to do this is simply to attach an event handler to #post-1 directly, since you aren’t making any savings by attaching to the parent.

    There aren’t 6 separate #post-1 elements you need to attach the handler to, so there is no point in delegating the event.

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

Sidebar

Related Questions

I'm currently writing a client-side javascript app which performs image manipulation. Some of the
symfony: http://www.symfony-project.org pjax: https://github.com/defunkt/jquery-pjax Hi all, I'm trying to use pjax in symfony in
I'm currently trying to check wether there is a new update of my app
I have 1 function in my debug model which i want to use in
Can anyone give me a solution for traversing a binary tree in inorder without
I am running a logistic regression in R and doing backward elimination inorder to
Having Trouble with Entity Framework. I have been populating EntityReferences with an EntityKey inorder
I need to perform an equals comparison in my template, inorder to do a
in order to recover data from server I use XMLHttpRequest and my code is
in order to avoid copy/paste, i can use a unique view for different actions,

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.