GodSpeed JP1
Posts: 0
Joined: Thu Feb 27, 2014 1:23 pm

How can set change a Label text of seleced row in list?

Hi,
I hava a dynamic list.
In listitem there is a Label.
When I click a row(listitem),I want to change the Lable of the row.
I defind a click event on the listitem,and run a javascript like:
Appery('LabelName').text("something");
But Only the first row changed to "something".
I think the reason may be all of the list items have a same name?I am not sure.
I want to change the Lable of selected row which I clicked, Not all of them nor the first one.
How can I fix it?
Thank you!

Nikita
Posts: 0
Joined: Fri Feb 28, 2014 4:02 pm

How can set change a Label text of seleced row in list?

Hello,

Please add handler to listitem's click event:
$(this).find("[name=LabelName]").text("something");

GodSpeed JP1
Posts: 0
Joined: Thu Feb 27, 2014 1:23 pm

How can set change a Label text of seleced row in list?

Sorry Nikita,
I user your method but it doesnot work.
My label name is 'count',so I tried below:
$(this).find("[name=count]").text("something");
$(this).find("[count]").text("something");
$(this).find("count").text("something");
and alert($(this).find("count").text());
It returns nothing("").
Anthing wrong?

GodSpeed JP1
Posts: 0
Joined: Thu Feb 27, 2014 1:23 pm

How can set change a Label text of seleced row in list?

by the way,I am not using list object ,I am using grid to loop just like a list.Is a grid different from list?

GodSpeed JP1
Posts: 0
Joined: Thu Feb 27, 2014 1:23 pm

How can set change a Label text of seleced row in list?

I am changing it to list object, I will try again.

GodSpeed JP1
Posts: 0
Joined: Thu Feb 27, 2014 1:23 pm

How can set change a Label text of seleced row in list?

It doesnot work in list object too.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

How can set change a Label text of seleced row in list?

Hello! Looks like you've done something wrong because code works. Could you post some screenshots so we can see what you have?

GodSpeed JP1
Posts: 0
Joined: Thu Feb 27, 2014 1:23 pm

How can set change a Label text of seleced row in list?

Hello Maryna,
Here is my page scrennshots,
Image

When I tap the row , I want change the number ('likecount') in red cycle in picture.

Tap event runs javascript below:
///////////////////////////////////////////////////////////////////////////////
var likecommentarr =[];

var comment_id = localStorage.getItem("_comment_id");

var likecommentstr = localStorage.getItem("_likecomment_array");

if (likecommentstr !== null && likecommentstr !== "") {
likecommentarr = JSON.parse(likecommentstr);
if (likecommentarr !== null && $.inArray(comment_id, likecommentarr)=0) {
alert("you have already click this comment!");
return;
}
}

updatebbscommentlikecountparse.execute({
success:function(data){

Code: Select all

    [b] $(this).find('[name=likecount]').text(data.likeCount);[/b] 
     alert($(this).find('[name=likecount]').text());// pop up space 

     if (likecommentstr !==null && likecommentstr !=="") { 
         likecommentarr = JSON.parse(likecommentstr); 
     } 
     if (likecommentarr !== null) { 
         likecommentarr.push(comment_id); 
     } else { 
         likecommentarr = []; 
         likecommentarr.push(comment_id); 
     } 
     if (likecommentarr.length  10) { 
         likecommentarr.shift(); 
     } 

     localStorage.setItem("_likecomment_array", JSON.stringify(likecommentarr)); 
 }, 
 error:function ( jqXHR, textStatus, errorThrown ) { 
     alert("error44"); 
 } 

});
///////////////////////////////////////////////////////////////////////////////

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

How can set change a Label text of seleced row in list?

Hello.

There is an issue in variables scope. To fix this please replace your code:
pre

updatebbscommentlikecountparse.execute({
success:function(data){

$(this).find('[name=likecount]').text(data.likeCount);
alert($(this).find('[name=likecount]').text());// pop up space

/pre
with the following one:
pre

var currentItem = jQuery(this);

updatebbscommentlikecountparse.execute({
success:function(data){

currentItem.find('[name=likecount]').text(data.likeCount);
alert(currentItem.find('[name=likecount]').text());// pop up space

/pre
This links should be helpful:
http://javascriptissexy.com/javascrip...
https://developer.mozilla.org/en-US/d...

GodSpeed JP1
Posts: 0
Joined: Thu Feb 27, 2014 1:23 pm

How can set change a Label text of seleced row in list?

Thank you Igor,Maryna and Nikita.
It works perfect.

Return to “Issues”