1

I am using the following piece of code

function showContacts(records) {    
    $j('#cList').empty();
    $j.each(Contacts.data(),
        function() {
        var newLi = $j('<li></li>');

            var newLink = $j('<a id="' +this.Id+ '" data-transition="flip">'+'<img class="myListimage" src='+this.pic__c+'></img>' +this.FirstName+ ' '+this.LastName+ '</a>');
        newLink.click(function(e) {
            e.preventDefault();
            $j.mobile.showPageLoadingMsg();
            $j('#fName').val(Contacts.findRecordById([this.id]).FirstName);
            $j('#lName').val(Contacts.findRecordById([this.id]).LastName);
            $j('#phone').val(Contacts.findRecordById([this.id]).Phone);
            $j('#email').val(Contacts.findRecordById([this.id]).Email);
            $j('#pic').val(Contacts.findRecordById([this.id]).pic__c);
            $j('#contactId').val(Contacts.findRecordById([this.id]).Id);
            $j('picture1').val(Contacts.findRecordById([this.id]).Picture__c);
            $j('#error').html('');

            $j.mobile.changePage('#detailpage', {changeHash: true});
        });
        newLi.append(newLink);            
        newLi.appendTo('#cList');
      //  x++;
      });

    $j.mobile.hidePageLoadingMsg();
    $j('#cList').listview('refresh');
}

I am displaying it in

<div data-role="content" >
    <li><a href="#"><img src="pic"/></a></li>
    <div data-role="fieldcontain">
        <label for="fName"><b>First Name:</b></label>
        <output name="fName" id="fName" />
    </div>
    <div data-role="fieldcontain">
        <label for="lName"><b>Last Name:</b></label>
        <output name="lName" id="lName" />
    </div>
    <div data-role="fieldcontain">
        <label for="phone"><b>Phone:</b></label>
        <output name="phone" id="phone" />
    </div>....

The image is not being displayed. Please let me know if anyone can figure it out Thanks

1
  • 1
    What is picture1 here? $j('picture1').val(Contacts.findRecordById([this.id]).Picture__c);
    – SE_User
    Commented Jul 21, 2016 at 9:57

2 Answers 2

1

do you have any 'picture1' tag or is it a id if latter is the case you should prepend a # to picture1 in the below line:

       $j('picture1').val(Contacts.findRecordById([this.id]).Picture__c);

if still out of luck show the console error if any and how u are rendering the image src with value of the tag.

1

In Html add id to the element

<img id="img" src="pic"/>

In script set src through jQuery attr method

$( "#img" ).attr( "src", Contacts.findRecordById([this.id]).pic__c);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .