Distinct Backgrounds for Each Titanium TableView Row

I have 5 categories of data on my WordPress blog and in my Titanium mobile app, I added row backgrounds to my rows. However, all rows have the same background. How can I set a different background for each row?

View my normal table view screen here:

View my added row background image screen here:

Here is my Categories .JS code:

$.init = function() {

var rows = [];  
getCategories(function(_data) {

for (var x = 0; x < _data.length; x++) {

    rows.push(Alloy.createController('category-item', {
        data : _data[x]
    }).getView());

}

$.categories_table.setData(rows);

APP.Loading.hide();
});

And here is my categories-items.js code:

$.c_title.text = args.data.name  ; 
$.c_counts.text = args.data.count  ; 
$.row.Item = args.data;
$.row.backgroundImage = 'durum.png';

Answer №1

Implement

$.row.backgroundImage = args.data.bgImg;

Don't forget to include bgImg in your data object (alongside name and count).

Answer №2

To pass args.anyParam, you simply need to follow the same process.

In a nutshell:

$.row.backgroundImage = args.data.bckImg; // This value varies for each data object you send to the controller

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

React error: Unable to use 'in' operator to find 'length' in null

I am trying to access and filter a local array file, then store the filtered array as a state before passing it to a child component. // Sample array file const originalData = [ { "ComName":"A", "SDGs":"1", " ...

What is the best method for dynamically binding Tailwind classes in VueJS3/NuxtJS3?

Is there anyone who knows how to correctly bind the content Tailwind class dynamically in Vue.js 3/Nuxt.js 3? Let's say we have const isExpanded = true <h1 :class="{'after:content-[`:`]' : isExpanded}">Hello</h1> I att ...

endless cycle when utilizing useEffect with a mandatory function

I'm currently in the process of creating a custom hook for sorting and filtering tables within a dashboard application. However, I am encountering an issue with an infinite loop when attempting to refetch data after changing sort or filter fields. The ...

Issue with Promise failing to trigger .then() following fetch to Express API/Mongoose request

Can someone shed light on why I am unable to return a promise and invoke .then() on it? I am creating an inventory system for my collection of Pokemon cards using a react front-end and an express backend. When I click the "increase inventory" button on th ...

The transmission of ContentType is unsuccessful

I'm having an issue with the code in my app. It seems that the content-type is not being sent. Is there a way to force it to be sent? $.ajax({ crossDomain: true, type: ...

To dismiss the Div, simply click on any area outside of it. Leveraging the power of SVG, D3

I need a way to hide my div by clicking outside of it. My SVG has a background and a graph with nodes on top of that. I have a special node (circle) on the graph, clicking on which makes a box appear. To show the box, I use the following code: d3.select ...

React - the constructor binding issue with 'this' keyword

I am a beginner in React and I am learning through creating a simple test application. However, I am facing an issue with "this" binding. I set up this app package yesterday using "create-react-app", so all the necessary plugins including babel should be u ...

What is the best way to create a function that can disable console.log and be imported into other React files for easy access?

Here is the content of my static.js file: var Helper = { console.log: function(){ }, Login: function(){ var name; var password; //rest of the code } } module.exports = Helper; Now, in my test.js file: var Helper ...

Translating SQL to Sequelize Syntax

I have an SQL query that I need to rewrite as a sequelize.js query in node.js. SELECT historyTable1.* FROM table1 historyTable1 WHERE NOT EXISTS ( SELECT * FROM table1 historyTable2 WHERE historyTable2.id=historyTable1.id AND historyTable2.da ...

Steps to restrict input in a text area to only backspace and cursor movements

I'm in search of a jQuery function that restricts movements to only arrow keys and backspace within a textarea. However, there seems to be an issue with the arrow key movements not functioning correctly. function moveArrow(e){ if(e.which >= 3 ...

Issue with retrieving POST body from Ajax call in Play Framework

I am currently attempting to send a POST request to my backend using JSON data. The frontend call appears like this: function register() { var user = $("#form_reg_username").val(); var pass = $("#form_reg_password").val(); var referal = $("#form_reg ...

Exploring jQuery's parent selector for traversing the DOM

I am currently working with an array that inserts articles into my website. I have a specific requirement where, upon clicking the title (h3), I need to display more information based on the article's index. To achieve this, I believe I should travers ...

Unable to utilize a computed property within the data section

I am working with an array in my data: data () { return { steps: [ { disabled: this.someCheck } ] } } Additionally, I have a computed property: computed: { ...mapGetters({ getFinishedSteps: 'jobFound/getFinishedS ...

Visibility of Code in AngularJS

After inspecting the source code of a website built with Angular today, I came across a snippet that made me ponder whether it's advisable to have such elements visible to everyone. ul class="nav-account desktop-only" ng-show="!User.isAuthenticated" ...

Switching from JavaScript to TypeScript resulted in React context not being located in its respective file

I previously had my context and context provider set up in a file, and everything was working perfectly. However, I recently decided to convert all of my files to TypeScript, including this one. Unfortunately, I've encountered a strange issue that I c ...

Having issues retrieving and utilizing response status code following the initial then() method in a Promise

My goal is to utilize the response status code, which is initially available in the first then function along with the JSON response data. However, I am encountering a SyntaxError: Unexpected token U in JSON at position 0. Here is the snippet of the promi ...

PHP echo functions are not functioning properly in a dynamically loaded PHP page through jQuery's .load function

Within my WordPress installation, I have index.php and desktop.php files. The goal is to load desktop.php into #tLoad only if the browser window width is greater than 800px. While this works fine, I am encountering issues when trying to use PHP functions a ...

Utilizing .html() to convert JSON data into HTML content

I have thoroughly commented the code below in my attempt to retrieve JSON data and pass it to the 'results' div in my HTML view. However, this process seems to return nothing, making it challenging to debug since no output can be displayed on the ...

Bringing in functions - NodeJS - non-HTML

Currently, I am in the process of learning automation for my job and have hit a roadblock. In times like these, stackoverflow has proven to be a life-saving resource :) My current task involves writing a Selenium test in VisualStudio using JavaScript (nod ...

Exploring the power of jQuery's deferred method and utilizing the ajax beforeSend

Using the deferred object in $.ajax allows for: Replacing the success-callback with the deferred-method done() Replacing the error-callback with the deferred-method fail() And replacing the complete-callback with always() When using: var jqxhr = $.ajax ...