Stop click event from firing on a disabled tree node within an angular custom directive template

In the browser, my custom Angular tree component is displayed like this:

+ Parent 1
   + Child 1-A
      - Child 1-A-A
      - Child 1-A-B
      - Child 1-A-C
   + Child 1-B
   + Child 1-C

This is what the directive template looks like:

<ul>
   <ers-tree-item ng-if="ctrl.parentItem"
               ng-repeat="item in ctrl.parentItem.children"
               item="item"
               parent="ctrl"
               level="ctrl.level"
               collapse-icon="ctrl.collapseIcon"
               expand-icon="ctrl.expandIcon"
               item-renderer="ctrl.itemRenderer"
               item-loader="ctrl.itemLoader"
               lazy-options="ctrl.lazyOptions"
               ng-disabled="ctrl.disabled"
        >
   </ers-tree-item>
</ul>

Each "li" element in the list, representing each Parent and Child in the tree, is created by the ers-tree-item directive using the template below:

 <!-- ers-tree-item directive -->
<li draggable="{{treeController.treeDraggable && !item.data.disabled && !disabled}}">
  <a href="javascript:void(0);"
    tabindex="0"
    draggable="false"
    ng-class="{'selected': item.selected}"
    ng-click="onItemClick()"
    ng-disabled="item.data.disabled || disabled">

     // The "+" or "-" icon and label for each tree item (i.e. Parent 1) are within this element
  </a>
</li>

I am looking to disable the click event only on the li element that is disabled. For example, if a tree node like Child 1-A is disabled, I want to prevent it from being dragged. Since all tree nodes have the same structure, I am struggling to figure out how to selectively disable the click event on disabled nodes.

Currently, I can prevent dragging on disabled elements, but the issue is when a disabled child node is dragged, the entire "ul" element gets dragged. Hence, I believe disabling the click event on disabled tree nodes might be the solution.

Answer №1

Enhance your design with a touch of CSS:

.myClass input:disabled {
    pointer-events: none;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Encountering an issue where I am unable to access properties of undefined (specifically 'up') within Material UI styling

I encountered an error message Uncaught TypeError: Cannot read properties of undefined (reading 'up') while executing the code snippet below: I am having trouble with compiling my react js Code Snippet from Index.js import React from 'react ...

Exploring the navigation features and states within the world of the Ionic framework

I am in the process of creating an app that saves information locally the first time it is used. My goal is for a different page to be displayed each subsequent time the app is opened. However, I am facing an issue with loading a simple page (not a templat ...

What are the steps to kick off my React App once I've cloned it?

Currently grappling with deploying my app using Netlify, I encountered an issue after cloning the app onto my new computer. > <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8afee5eee5e6e3f9fefcb8cabba4baa4ba">[email  ...

The outcomes of JSON.stringify and JSON.parse can vary

I am facing an issue with using JSON.stringify to create a JSON string from an Object. After saving the string into a file, I attempt to read the file and use JSON.parse to retrieve the object again. However, it seems that the process is not working as exp ...

Angular: Exploring the differences between $rootScope variable and event handling

I have a dilemma with an app that handles user logins. As is common in many apps, I need to alter the header once the user logs in. The main file (index.html) utilizes ng-include to incorporate the header.html I've come across two potential solution ...

Streamline Access to Zimbra Server Automatically

Currently, I am creating a webpage with a login feature at www.newpage.com. Here is the code snippet for reference: <form name="login"> Username<input type="text" name="userid"/> Password<input type="password" name="pswrd"/> <input ty ...

Using the CSS property `absolute` can result in the input element shifting when entering text in Chrome

My grid layout is causing some issues with the search box placement. Whenever a user starts typing in the input box, it jumps to the other side of the page. After investigating, I realized that the culprit is the position: absolute property. Oddly enough, ...

Manipulating images live with options for scaling, resizing, and cropping

I am currently developing a content management system that allows users to upload images and attach them to different sections of the pages. My goal is to find a user-friendly, preferably jQuery-based plugin for resizing images before they are cropped. A ...

Unable to display toast notification in React/MUI/Typescript project

Currently tackling error notifications targeted at 400,401, and 500 errors within a large-scale project. I am facing an issue where I want to integrate my ErrorToastNotification component into my layout.tsx file to avoid duplicating it across multiple page ...

Dynamically change the content of the DataTable by utilizing jQuery

I am facing an issue with updating a DataTable using jQuery when the contents of the table are modified. Initially, I have a HTML table with an empty tbody, which is populated dynamically based on selected filters such as select options. The table uses Dat ...

Visual traceroute, like the one on "yougetsignal.com", provides a way to update a div element either on demand or periodically

This is my very first question on a forum, yay! I will do my best to ask clearly and concisely. I am currently working on creating a visual traceroute similar to the one found on yougetsignal.com by Kirk Ouimet. My project is up and running using bash co ...

Updating the content within a div following the submission of a contact form 7

I'm struggling with my contact form. I want the content of my contact form div to change after clicking submit on the form. I've been searching for a solution, but so far, no luck. Here is what I have: Form (div1) with input fields, acceptance c ...

Attention! Are you aware of the potential consequences of the impending phase-out of the name attribute in W3C validation? Have you considered how this development

Any thoughts on what could replace the name attribute? According to the W3C validator... Validation Output: 4 Warnings Here is a list of the warning message(s) generated while checking your document. Warning Line 12, Column 21: The name attribute i ...

THREE.JS ensures that the face normal is perpendicular to the face and facing outward

When using THREE.JS to generate a custom geometry, I define vertices and faces. However, when creating a face without specifying the normal direction like new THREE.Face3(a,b,c), some faces end up pointing inward instead of outward. Is there a way to ens ...

The drop-down menu is misaligned from its designated position underneath the title

Trying to incorporate a dropdown menu into my website, I am structuring the HTML as follows: <ul class="topnav"> <li> SECTION TITLE <ul class="subnav"> <li>One</li> <li>Two</li> ...

Refresh Content Using Ajax with jQuery Mobile's Link Click or Browser's Back Button

Alright, I've exhausted all options, time to seek advice from the professionals! I'm dealing with a multi-page JQM app. index.html - serves as the starting point and retrieves a list of projects via Ajax, everything is functioning perfectly - g ...

Struggling with AJAX requests in a cordova/ratchet app for mobile devices

I encountered some challenges when trying to make an AJAX request in my cordova project. $.ajax({ url: "https://mydevserver/REST.php?method=mobileGetData", success: function(result){ alert("successful ajax"); }, error: function(xhr ...

Red X appearing in IE9 for HTML5 Video

It's strange that my video works on some browsers but not others, even though I'm using mp4, ogv, and webm formats. Even weirder is that some videos work while others don't. To illustrate the issue, I've created a jsfiddle for you to c ...

Can a placeholder dropzone be created at the bottom of Vue Draggable lists?

Currently, I am utilizing Vue.Draggable (accessible at https://github.com/SortableJS/Vue.Draggable) to develop a kanban board that enables me to drag items from one list to another. A challenge I face is that when dragging a list item to the bottom of anot ...

I am struggling to create a responsive form using Bootstrap

I am facing an issue with my two forms that I want to have a fixed full-screen size. Despite trying different bootstrap options, they are not responsive at lower resolutions. What should I do to make them responsive? Here is the code: <form action=&a ...