The JQuery TextNTags plugin eliminates tag formatting once the trigger syntax has been modified

I have incorporated the JQuery TextNTags plugin into my web application. Here is the original code snippet:

$.browser = {
    webkit: true
};
$(function () {
    $('textarea.tagged_text').textntags({
        triggers: {'!': {
            uniqueTags   : false,
            syntax       : _.template('![<%= id %>:<%= type %>:<%= title %>]'),
            parser       : /(!)\[(\d+):([\w\s\.\-]+):([\w\s@\.,-\/#!$%\^&\*;:{}=\-_`~()]+)\]/gi,
            parserGroups : {id: 2, type: 3, title: 4},
        }, '#': {
            uniqueTags   : false,
            syntax       : _.template('#[<%= id %>:<%= type %>:<%= title %>]'),
            parser       : /(#)\[(\d+):([\w\s\.\-]+):([\w\s@\.,-\/#!$%\^&\*;:{}=\-_`~()]+)\]/gi,
            parserGroups : {id: 2, type: 3, title: 4},
        }, 'PP:': {
            uniqueTags   : false,
            syntax       : _.template('PP:[<%= id %>:<%= type %>:<%= title %>]'),
            parser       : /(PP:)\[(\d+):([\w\s\.\-]+):([\w\s@\.,-\/#!$%\^&\*;:{}=\-_`~()]+)\]/gi,
            parserGroups : {id: 2, type: 3, title: 4},
        }},
        onDataRequest:function (mode, query, triggerChar, callback) {
            var data = {
                '!': [
                    { id:1, name:'Daniel Zahariev (via !)',   'img':'http://example.com/img1.jpg', 'type':'contact1' },
                    { id:2, name:'Daniel Radcliffe (via !)',  'img':'http://example.com/img2.jpg', 'type':'contact1' },
                    { id:3, name:'Daniel Nathans (via !)',    'img':'http://example.com/img3.jpg', 'type':'contact1' }
                ],
                '#': [
                    { id:4, name:'Daniel Zahariev (via #)',  'img':'http://example.com/img1.jpg', 'type':'contact2' },
                    { id:5, name:'Daniel Radcliffe (via #)', 'img':'http://example.com/img2.jpg', 'type':'contact2' },
                    { id:6, name:'Daniel Nathans (via #)',   'img':'http://example.com/img3.jpg', 'type':'contact2' }
                ],
                'PP:': [
                    { id:7, name:'Daniel Zahariev (via PP:)',  'img':'http://example.com/img1.jpg', 'type':'contact3' },
                    { id:8, name:'Daniel Radcliffe (via PP:)', 'img':'http://example.com/img2.jpg', 'type':'contact3' },
                    { id:9, name:'Daniel Nathans (via PP:)',   'img':'http://example.com/img3.jpg', 'type':'contact3' }
                ]
            };

            query = query.toLowerCase();
            var found = _.filter(data[triggerChar], function(item) { return item.name.toLowerCase().indexOf(query) > -1; });

            callback.call(this, found);
        }
    });



    $('.get-syntax-text4').click(function() {
        $('textarea.tagged_text_ex4').textntags('val', function(text) {
            alert(text);
            console.log(text);
        });
    });
});

In an attempt to modify this code, I am striving to alter the syntax of each trigger by eliminating :<%= title %>. However, upon doing so, I noticed that it removes the tag background color. To visualize this change, please view the fiddle before modification: http://jsfiddle.net/6205ef8j/6/ and after modification: http://jsfiddle.net/6205ef8j/7/

I am seeking insights on why this behavior occurs.

Additionally, another question arises which seems connected to the previous issue. Can someone clarify the purpose of parserGroups? The documentation mentions:

Object that maps the indexes of the parsed groups with the corresponding tag properties.

However, I find this definition somewhat challenging to comprehend.

Answer №1

The design is created with a distinct layered div element where the title is crucial for formatting the text. It is important to retain the title if you wish to utilize the edit mode.

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

Execute jquery commands after the function has finished

I am trying to implement the code below: $(":file").change(function () { if (this.files && this.files[0]) { console.log(this.files[0]); var reader = new FileReader(); ...

Checking the efficiency of Graphql API

Currently, I am in the process of optimizing key features within my Node.js API which incorporates GraphQL. This API serves as a proxy, receiving requests from various sources and forwarding them to multiple APIs based on the request. I am interested in ...

SVG Mask not functioning properly with SVGs created in Illustrator (in all web browsers)

Alright, let's get to it - I've got a couple of SVGs here. The first one is a blue circle and the second one is a map of the United States. (Both of these were created in Illustrator) Here's what I want to do: I want the map to serve as a ...

Emulate a link click using key input

Hey there! I have this link example: <a href"http://google.es">Link</a> I'm wondering if it's possible to use JavaScript or a similar tool so that when I press a specific key, like the number 5 on the keyboard, it acts as if I click ...

Error message 800A03EA in Windows Script Host encountered while running Express.js script

I'm currently diving into the world of JavaScript development, following along with the guidance provided in the book called "JavaScript Everywhere." The book instructs me to execute the following code: const express = require('express' ...

Set $scope.model childs to an empty string or a null value

While working on a form, I am using a $http request to send the information through Angular in the following manner: $http({ method:"POST", url: "controllers/servicerequest.php", data: { servicerequest: $scope. ...

Increase the size of the class element when hovered over

I have assigned a class to the "next" and "previous" functions on my webpage, and I am interested in increasing their size on hover so that they take up more space and push the other elements aside. For example: When I hover over the NEXT button, I want i ...

Transmitting information in segments using Node.js

Recently delving into the realm of nodejs, I find myself tackling a backend project for an Angular 4 application. The main challenge lies in the backend's sluggishness in generating the complete data for responses. My goal is to send out data graduall ...

Passing state updates between child components by utilizing the useReducer hook and dispatching actions

Check out this interactive example on CodeSandbox with the code provided and highlighted linting issues: https://codesandbox.io/s/react-repl-bw2h1 Here is a simple demonstration of my current project setup. In a container component, there is an important ...

Collaboratively utilizing resources among various NPM Workspaces

Currently, I am working on a React project using NPM Workspaces. I have created an 'assets' workspace within this project to store all images and assets that need to be accessed by other workspaces. The directory structure of the project is as fo ...

The charset is failing to function properly when using the French language

Encountering an issue with the French language on a website I'm currently developing ... Specifically, there are menu bars, tabs, and text within each tab involved. Upon setting charset=ISO-8859-1, the body text functions correctly, but the menu bar ...

Designing HTML Emails Using Nested Tables

Why is my text-decoration="none" not displaying properly? I have tried placing it in various locations like table, tr, td, but I am unable to make it work. Are there any common mistakes when styling email designs? Here is the code snippet: <table cel ...

Combine two scope arrays in AngularJS

Is there a way to merge two arrays of scope in AngularJS within my controller so that I can display them in a single table? The merging would be based on a common field present in both arrays, similar to an SQL join operation where data from both tables ...

Creating a Fixed Footer with CSS

Another question on the same topic, with a twist. Despite trying various solutions found in countless articles, none seem to work for me. My familiarity with HTML/CSS is limited due to just a few months of off-and-on practice. Hence, I'm seeking help ...

Tips for enabling the auto complete feature in your settings

I have multiple websites similar to Facebook where users input an email address and by clicking a button, a list of email addresses is displayed. Could someone please explain how this functionality is created? Can it be accomplished using only HTML or are ...

Exploring the world of web programming

Looking for top-notch resources to learn about JavaScript, AJAX, CodeIgniter and Smarty. Any recommendations? ...

The issue with IE-9 is that it is mistakenly picking up the placeholder value as

My HTML code looks like this: <input id="SLOCriteriaOtherText" name="SLOCriteriaOtherText" style="width: 100%;" type="text" data-role="autocomplete" placeholder="Enter name for 'other' metric..." class="k-input" autocomplete="off" role="textb ...

Webster Barron code script

I'm attempting to replicate the concept of this video https://www.superhi.com/video/barron-webster using text, but I am encountering difficulties in achieving the desired effect. The design text is currently overlapping my name and displaying in rev ...

Hide the popup menu when the user clicks outside of it

I am presenting the following code <!DOCTYPE html> <html> <head> <title>GalacticCraft</title> <link rel="stylesheet" type="text/css" href="style.css" /> <link rel="shortcut icon" type="image/png" href="fa ...

Refine objects based on their properties without removing them from the dataset

I have a specific object structured as follows: var myObj: { 2:"None", 20:"A", 31:"A", 32:"A", Social:"B", Method:"None" } My goal is to retrieve the object without the properties 'Social' and 'Method'. Initia ...