I’m confused

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!
1 person has
this question
+1
This topic is no longer open for comments or replies.
  • 1
    Hello,

    Please add handler to listitem's click event:
    $(this).find("[name=LabelName]").text("something");
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • 1
    Hello! Looks like you've done something wrong because code works. Could you post some screenshots so we can see what you have?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • Hello Maryna,
    Here is my page scrennshots,


    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){

    $(this).find('[name=likecount]').text(data.likeCount);
    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");
    }
    });
    ///////////////////////////////////////////////////////////////////////////////
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • 1
    Hello.

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


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

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


    with the following one:


    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


    This links should be helpful:
    http://javascriptissexy.com/javascrip...
    https://developer.mozilla.org/en-US/d...
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned

  • I’m happy
    Thank you Igor,Maryna and Nikita.
    It works perfect.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. happy, confident, thankful, excited sad, anxious, confused, frustrated kidding, amused, unsure, silly indifferent, undecided, unconcerned