Error Icon Displayed Incorrectly in Dynamically Generated List Items in Phonegap Android App

My attempt to dynamically create a list item with JSON response and set the data-icon to "check" is not working as expected. The result always shows "arrow-r" data-icon instead.

This is how I generate the list item:

function CallvarURL(url) {
    var respPrice ;
    $.ajax({
        url: url,
        type : "GET",
        dataType : "json",
        contentType: "application/json",
        async : false,
        success : function(msg) {
            respPrice = msg;
            $("#varList li").remove();
            $.each(respPrice.Value, function(index, value) {
                if(value.SubVar_id == 'NoDataFound' ) {
                    alert('No product is assigned to '+ localStorage.getItem('userId') +  ' for update the price please contact your admin.');
                } else {                        
                    vari = value.SrNo;
                    commVari = value.subVar_eng_name;
                    minPrice = value.Frm_price;
                    maxPrice = value.to_price;
                    var update = value.TimeCheck;
                    if (update == 'Y') {
                        $respPrice = '<li data-categoryId = "'+ vari +'" data-categoryId2 = "'+ minPrice +'" data-categoryId3 = "'+ maxPrice +'" data-categoryId4 = "'+ commVari +'"><a href="#" data-icon="star"><b class="stuff">' + commVari + '</b><br><b class="tcolour">' + minPrice + ' - ' + maxPrice + '</b></a></li>';
                    } else {
                        $respPrice = '<li data-categoryId = "'+ vari +'" data-categoryId2 = "'+ minPrice +'" data-categoryId3 = "'+ maxPrice +'" data-categoryId4 = "'+ commVari +'"><b class="stuff">' + commVari + '</b><br><b class="tcolour">' + minPrice + ' - ' + maxPrice + '</b></li>';
                        }
                     $('#varList').append($respPrice);  
                    };
                });

I'm unable to figure out why this is happening. I've tried changing the values for data-icon but it always displays "arrow-r". Any assistance would be appreciated.

Answer №1

It seems like you are utilizing jquery mobile based on your question. I have created a list with checkboxes in the following jsfiddle link. The right arrow in your code is likely due to it being included in a tag, as jquerymobile automatically adds right arrows.

Feel free to check out this jsfiddle for more details: (jsfiddle.net/4FdcY/366/) I hope this helps!

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

Generating elements with the help of node.js and express.js

Currently, I have an application that operates entirely on the client-side. When an XML file is uploaded to the app, it uses jQuery to create new elements and display them on the page. The content of these elements varies based on the uploaded file's ...

jQuery efficiently handles large amounts of text data transfer (gradual loading)

The issue at hand: My website relies on jQuery AJAX (post) for navigation, meaning the page doesn't refresh every time a user moves to a different section. This setup requires me to fetch data using AJAX and present it dynamically. While this works w ...

Activate a change or response when the input value in Javascript is altered

Currently, I am working on a small project using JQuery and facing an issue when trying to remove error classes from HTML elements. To handle the removal of the error classes, I am utilizing $('selector').on('input') event to target th ...

Using AngularJS and the ng-show directive, you can set a <div> element to

Objective: My aim is to show the content of a div according to the status of checkboxes, while also ensuring that these divs are visible by default If I have this code snippet: <html> <head> <script src="https://ajax.googleapis.com/ajax/li ...

Creating a sleek grayscale effect when hovering with CSS is both simple and effective

My website features a grayscale logo that smoothly transitions to color upon hover. However, I am experiencing some issues with the smoothness of this transition when using CSS. Here is my current code: <img alt="TT ltd logo" src="./img/tt-logo.png" c ...

Setting up button value dynamically according to dropdown selection in Angular 2

I'm a beginner in angular 2 and I have a button with a dropdown. When I select an option from the dropdown, I want its value to be displayed on the button. The CSS code for styling the dropdown is provided below: .common_select_box { width: 100%; } ...

Organize chat messages based on date using JavaScript

I came across a similar query, but it didn't resolve my issue. Check this out: How can I group items in an array based on date? My goal is to organize these chat messages by date after fetching them from the database using AJAX. The console displays ...

What is the solution to incorporating a scrollbar in a popup when I increase the zoom level?

When trying to add a scrollbar to the popup, I am facing an issue where the scrollbar does not appear when zoomed in to 75% or 100%. It works fine for fit screen but not on zoom. Can anyone help me identify what is wrong with my code and suggest how to han ...

What is the process for implementing a context menu in datatables version 1.10?

I need to enhance my table using DataTables from datatables.net by adding a context menu feature. Upon researching, I came across the jQuery contextMenu plugin and found some information in the DataTables forum about implementing a context menu. However, ...

PHP MySQL table submission button

Here is the content I have: <table class="sortable table table-hover table-bordered"> <thead> <tr> <th>CPU</th> <th>Speed</th> <th>Cores</th> <th>TDP</th> <th> ...

Using jQuery's .load() method is like including a file in a

Currently, Im working on revamping a company website that comes equipped with its very own CMS. Unfortunately, we are restricted from accessing the server configuration and FTP, which means I am limited to running only client-side files like HTML/CSS/J ...

Replace the default disc icon with a more detailed icon for UL lists

I am working with an unordered list and I want to use <details> to show a sublist for one of the items: <ul> <li><details> <summary>details bullet</summary> <ul> <li>detail 1</li> ...

What are the steps to create a responsive form using CSS?

I have a screenshot below that needs to be recreated using HTML/CSS. This design should be consistent in both desktop and mobile views. https://i.stack.imgur.com/cnfHt.png Currently, I have managed to replicate this in a JSFiddle which looks good on desk ...

Ways to conceal a photo preview when the picture is not accessible in the galleriffic gallery

I have been searching high and low for a solution to this issue... Currently, I am utilizing the Galleriffic plugin on my website in order to showcase a gallery of images. My goal is to be able to update the images simply by adding them to a folder. Howe ...

Creating a vertical scrollable container that spans the full height of the PDF document

I am currently working on embedding a PDF file into my website. I'm trying to hide the status bar, including download buttons and page numbers, through some clever techniques so that I can control them externally. My goal is to be able to redirect use ...

Having difficulty retrieving the current time of an audio element using jQuery

Currently, I am facing an issue while attempting to manage an audio element for my custom player. Despite numerous attempts, I have been unsuccessful in acquiring the currentTime and duration properties. Below is a snippet of what I've tried: var pla ...

Steps for aligning a table in the middle of a webpage

Can someone help me align my table to the center of the webpage? I have tried using align="right" and "center" but neither seem to be working. Any tips on how to position the table correctly? <table style="table-layout:fixed;" align="right" cellspaci ...

What is the process for transferring a file's contents to my server?

I am currently working on allowing users to import an OPML file that I parse server-side in my Rails application. However, I am facing difficulties as it appears that my server is not receiving the information correctly (neither the success nor error funct ...

How can a callback be properly passed in programming?

My coding approach is outlined below: var CustomLibrary = (function (window, $, undefined) { return { URI: 'http://testpage/API/', OnSuccess: function (data, status) { }, OnError: function (request, status, error) { } ...

Is your window.location.hash malfunctioning?

I am facing an issue with changing the background color of a <div id="services> when a specific link (index.html#services) is clicked. I have attempted to use the latest jQuery along with the jQuery Color plugin from jQuery Color. The code snippet I ...