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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:15:49+00:00 2026-06-12T08:15:49+00:00

I have the following controller, that on start-up queries the server for a list

  • 0

I have the following controller, that on start-up queries the server for a list of items, which gets the basic details for all items. Then, when a user clicks on an item from the list, it queries the server to return all of the item information, including some SVG data.

function ItemsCtrl($scope, $http) {
  $scope.items = [];
  $scope.selectedItemDesign = null;

  $http.jsonp('/items/all?callback=JSON_CALLBACK').
    success(function (data) {
      $scope.items = data;
    });

  $scope.getItem = function (item) {
    var index = $scope.items.indexOf(item);
    if (!$scope.items[index].SVG) {
      $http.jsonp('/items/byid/' + $scope.items[index]._id + '?callback=JSON_CALLBACK').
        success(function (data) {
          $scope.items[index].SVG = data.SVG;
          $scope.selectedItemDesign = $scope.items[index].SVG;
        });
    } else {
      $scope.selectedItemDesign = $scope.items[index].SVG;
    }
  };
}

The SVG data is then bound directly to the view via:

<div class="span9" ng-bind-html-unsafe="selectedItemDesign">

The problem I have is that I want to be able to attach events to tags in the SVG so as to allow users to interact with the SVG (simple onClick events), but I can’t figure out how to do this…

I thought that after the line; $scope.selectedItem = $scope.items[index]; I would then be able to access the DOM and attach the events, but that isn’t the case (the DOM hasn’t been updated yet). I’ve looked at the information on directives too and while I’ve managed to get a directive set up to do the operations I need, it doesn’t fire when the SVG is changed (and even then I’m not sure if it’s pre/post DOM update).

  • 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-12T08:15:50+00:00Added an answer on June 12, 2026 at 8:15 am

    You’re right that you should be adding the onClicks to your SVGs after the DOM is rendered, and that that work should be done in a directive.

    The hard part (and this is a recurring issue) is that there’s no event that tells you when you should start adding those onClicks. Angular has no way of telling you, since it doesn’t know when the DOM is ready. You’ll have to add something to the directive that figures this out heuristically, by using jQuery to watch the DOM periodically with a setTimeout and figure out when it’s ready for you.

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

Sidebar

Related Questions

I have the following getJSON that calls an MVC controller which returns inforamtion back:
If i have a controller action Create that returns a view with the following
I have the following method that retrieves all the appointments between 2 dates: def
I have the following ember controller that is going to wait for json objects
I have the following controller action: [HttpGet] public JsonpResult getTestValues(int? entityId, int? id) {
I have the following controller: class Tests extends CI_Controller { public function update_record_test() {
I have the following controller: public ActionResult Search(string Name, int? Friend, int? Page) It
I currently have the following controller method in a Rails app: def index @entries
I have the following view controller in my UIPopover: @protocol StorePopoverDelegate - (void)storeSelected:(NSString *)store;
I have following spec to test controller method: context #create do it should redirect

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.