What is the method for adding a tag within a specific div ID in ExtJS?

I am looking to insert a new tag within existing tags using extjs, based on the div id 'task123', and also trigger an alert message accordingly.

Below is the HTML code snippet:

<div id="task123">
  <div class="msg" id="sample">
    <ul class="msg-icons"> editButton </ul>
    <h3>Task Details</h3>
    <div>Messages</div>
    <br/>
    <a class="closeMessageBox" style="cursor:pointer; float: right; font-size:7pt;">Click here to close</a>
  </div>
</div>

The task is to insert the new tag after the following line in the old tag:

<div>Messages</div>

With reference to the div id task123, here is the extjs code snippet:

 var iconDisplay = {}; 
   iconDisplay.html = '<div class="icon-right">' +'</div>'; 
   var icondisp =
   Ext.fly("task123").query('a.closeMessageBox');
                 Ext.core.DomHelper.insertBefore(icondisp[0], iconDisplay);

   Ext.fly("task123").select('div.icon-right').on('click', function() {
       alert("tested icon right...")    
   },_message);

It seems that the above code is not functioning properly as expected.

Answer №1

Here is a quick JavaScript snippet that adds a new element before a specific link:

var divNode = document.getElementsByClassName("closeMessageBox")[0];

var newNode = document.createElement("button");
newNode.innerHTML = "Click me";
divNode.parentNode.insertBefore(newNode, divNode.previousSibling);

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

Unable to interact with options in a dropdown menu while utilizing selenium

As a newcomer to the world of web scraping with Python using Selenium, I am trying to extract information on tennis players from the website "https://www.itftennis.com/en/players/". The challenge I am facing is related to navigating a drop-down list of res ...

JS Issues with generating accurate dates in JS/JS Date perplexities

Creating a custom datepicker has been a challenging task for me. I'm facing difficulties in understanding how JS Date works and need some assistance to bridge this knowledge gap. The issue arises when I attempt to generate dates using a for loop, resu ...

What is the most effective approach for managing exceptions at a global level in Node.js using Express 4?

Is there an Exception filter available in node.js with express 4, similar to the one in asp.net MVC? I have searched through various articles but haven't found a solution that meets my requirements. I also attempted the following in app.js: process ...

Update the height definition for the alert box

I need to adjust the height of my alert box, so I attempted the following: @alert-box: 60px; .alert-msg { height: @alert-box; margin: 20px 0px; } However, the outcome was In the image provided, it is evident that the text within the secon ...

Importing text data from a text file in Java or jQuery without the need for a web server

I've attempted to utilize both the jQuery.Get() and $.Get() methods for this task, but they don't seem to be working as expected. <head> <script type="text/javascript" src="jquery-2.1.3.min.js" > </script> <script lang ...

Shrink or vanish: Creating a responsive header image with Bootstrap

Looking to create a dynamic header with different sections such as headerright, headercenter, and headerleft, each with unique content. I've successfully added an image to the header, but when I resize the page or view it on a mobile browser, the ima ...

How to interrupt a JQuery animation and restart it from the middle?

Currently, I am tackling my first JQuery project and facing a challenge. As the user mouseleaves the .container, the animation does not reset but continues as if they are still within it. My goal is to have the animation revert in reverse if the user decid ...

The datetimepicker is not functioning properly

I'm experiencing an issue with the datetimepicker where it doesn't display a calendar when I click the icon. Interestingly, the Chrome browser isn't showing any errors in the development console. <script src="Scripts/jquery-2.1.1.min.js ...

Issues related to ng-model within a dropdown list

Currently, I am facing an issue with retrieving the selected value from a select element using ng-model. Even though the value is displayed correctly on the application page, it remains at the initial value in the app controller. Despite my efforts to find ...

CSS: text positioning issue observed in Mozilla browser

I am facing an issue with the text position inside the box/button element on my website. The text appears correctly in Chrome, but in Firefox, it is positioned above the box, making it difficult to read. Can someone assist me with fixing the CSS or identi ...

What is the process for automatically disabling a checkbox based on the condition that the value in another field is 0?

Before we proceed, feel free to check out the jsFiddle example provided: https://jsfiddle.net/1wL1t21s/ In my scenario, there are multiple checkboxes for selecting toppings with a quantity adjustment feature using the plus (+) and minus (-) buttons. Curre ...

Is there a way to have the user input data into a Firebase database directly from a Vue.js component?

Any assistance for a beginner like me would be greatly appreciated. I am currently working with vuejs and firebase to write data into the database from a vue component. I have successfully implemented authentication and writing functionality, but now I wan ...

The primary container is brimming with an abundance of content

Can anyone help me with a CSS issue I'm experiencing in the latest versions of Chrome and Firefox? I can't seem to figure it out on my own. The problem arises with a container div that has a 50px top margin. Inside this container, there's a ...

Ways to forward a parameter to a different web address?

Is there a way to properly redirect a parameter such as http://example.com/?link=https://google.com to its destination at ? ...

Exploring effective ways to visually display percentage data in Google Charts without relying on total sample size

Hey there! I'm currently working on creating Pie Charts using the Google Charts Library to showcase browser statistics from 2004. The total sample size is unknown, but for all I know, it could be a percentage of 1.2 billion. Here's how I've ...

Exploring the indexOf method in Jade

Currently using Jade and Express. '#{value.users}' is an array data type. '#{user.username}' is a string data type. Attempting to utilize the if '#{value.users}'.includes('#{user.username}') method. When true, I ...

Ensuring that objects remain fixed in place regardless of window resizing is a common task in web development, often achieved through a

I've been attempting to create range sliders with boxes that display the slider's current value, but I'm having trouble getting them positioned correctly when the window size changes. Despite trying various solutions found online, I resorted ...

Error: The function bind is not supported on instance[method] in the AdonisJs framework

I am currently integrating the MQTT-adonis module adonis-mqtt response on Git here in my adonis-js application. However, when trying to serve it, an exception is thrown. TypeError: instance[method].bind is not a function Could anyone provide guidance o ...

Create a substitute for Object.seal, Object.freeze, and Object.preventExtensions applications

Is there a way to freeze an object's existing properties while still allowing new ones to be added? I can't seem to find any built-in functionality for Object.freezeExisting(), so maybe it's worth considering implementing it, possibly even w ...

What methods are available to adjust the header color on various pages?

I have a solution that works for one location, but I need to add red color to multiple locations. How can I achieve this? import { useRouter } from "next/router"; function Header() { const router = useRouter(); return ( <> & ...