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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:51:34+00:00 2026-06-18T05:51:34+00:00

In my DOM in AngularJS, I am using an ng-include inside a ng-repeat directive.

  • 0

In my DOM in AngularJS, I am using an ng-include inside a ng-repeat directive. It is loading the HTML just fine. Anyway, an issue I have is that I’m using JQuery (latest version) to bind a few mouse over and mouse click events on elements in the DOM with the same class as those added to the DOM by the ng-repeat and include. JQuery doesn’t seem to apply the event handlers to the new DOM addition, though.

In previous versions .live() seemed to do what I want, but it has been removed in the latest version. Should I clear the bindings on the elements and re-create them every time the DOM has additional elements of the class added?

  • 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-18T05:51:35+00:00Added an answer on June 18, 2026 at 5:51 am

    Answer here:

    This is a multifaceted question. First of all, all jQuery code events should use $scope.$apply to execute angularjs code as expected. Example:

    jQuery(selector).someEvent(function(){
        $scope.$apply(function(){
          // perform any model changes or method invocations here on angular app.
        });
    });
    

    In the latest version of jQuery, in order to have events that update based on DOM changes, you want to 1. Get a selector for the nearest parent element (ex):

    <div class="myDiv">
    <div class="myDynamicDiv">
    </div>
    <!-- Expect that more "myDynamicDiv" will be added here -->
    </div>
    

    In this case, your parent selector would be “.myDiv”, and your child selector would be .myDynamicDiv.

    Thus, you want jQuery to have the events on the PARENT of the element so if the child elements change, it will still work:

    $('.myDiv').on("click", ".myDynamicDiv", function(e){
          $(this).slideToggle(500);
          $scope.$apply(function(){
               $scope.myAngularVariable = !$scope.myAngularVariable;
          });
    });
    

    Notice that the $scope.$apply() is used in order to enable jQuery to access those angular variables.

    Hope this helps!
    Christian

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

Sidebar

Related Questions

I'm using AngularJS to build HTML controls that interact with a legacy Flex application.
I am using Angularjs for a web application. I have tried searching to find
All, we're developing a webapp with AngularJS and we have a use case/requirement (that
I have been using DOM for a long time and as such DOM parsing
i am using DOM to get content of div tag but inner html part
I have the following DOM structure (unordered list), that I would like to sort
following on from this question: how to write a directive for angularjs that replaces
I have an AngularJS app that returns a list of json objects and I
Using AngularJS and UI Bootstrap, I want to dynamically add alerts to DOM. But
I am using a directive which modifies the DOM and therefore must be done

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.