views:

92

answers:

1

Please excuse the length of this post, but I needed to explain what I am seeing. I have a onSelectRow option that is supposed to build stacked html <li> tags (such as

<li>...</li>
  <li>...</li>
  <li>...</li>

) up to the number of static xml elements that I am looking at. But my script is concatenating all the image src links together instead of building the whole listobject tag. Everything else in my jqGrid script works with exception of repeated elements inside my xml.

onSelectRow: function() {
    var gsr = $('#searchResults').jqGrid('getGridParam', 'selrow');
    if (gsr) {
     var data = $('#searchResults').jqGrid('getRowData', gsr);
    $('#thumbs ul').html('<li><a class='thumb' href='' + data.piclocation + '' title='' + data.pictitle + ''><img src='" + data.picthumb  + "' alt='" + data.pictitle + "' /></a><div class='caption'><div class='image-title'>" + data.pictitle + "</div></div></li>");
};"

my xml file is something like this:

<photo>
            <pic>
                <asset>weaponLib/stillMedia/slides/A106.jpg</asset>
                <thumb>weaponLib/stillMedia/thumbs/A106.jpg</thumb>
                <caption>Side view of DODIC A106</caption>
                <title>Side view of 22 caliber long rifle ball cartridge</title>
            </pic>
            <pic>
                <asset>weaponLib/stillMedia/slides/A106_A.jpg</asset>
                <thumb>weaponLib/stillMedia/thumbs/A106_A.jpg</thumb>
                <caption>Side view of DODIC A106</caption>
                <title>Side view of 22 caliber long rifle ball cartridge</title>
            </pic>
            <pic>
                <asset>weaponLib/stillMedia/slides/A106_B.jpg</asset>
                <thumb>weaponLib/stillMedia/thumbs/A106_B.jpg</thumb>
                <caption>Side view of DODIC A106</caption>
                <title>Side view of 22 caliber long rifle ball cartridge</title>
            </pic>
            <pic>
                <asset>weaponLib/stillMedia/slides/A106_C.jpg</asset>
                <thumb>weaponLib/stillMedia/thumbs/A106_C.jpg</thumb>
                <caption>Side view of DODIC A106</caption>
                <title>Side view of 22 caliber long rifle ball cartridge</title>
            </pic>
            <pic>
                <asset>weaponLib/stillMedia/slides/A106_D.jpg</asset>
                <thumb>weaponLib/stillMedia/thumbs/A106_D.jpg</thumb>
                <caption>Side view of DODIC A106</caption>
                <title>Side view of 22 caliber long rifle ball cartridge</title>
            </pic>

My script works fine when it only sees one sequence, but when it sees more than one it puts all html inside the tags together then for the caption and title does the same for them. It generates only one <li></li> tag set instead of 5 in the example above like I want.

The <li> tags are being used by a slideshow (with thumbnails) utility.

Inside firebug, I can see the object that it is built for me:

<a title="Side view of 22 caliber long rifle ball cartridgeSide view of 22 caliber long rifle ball cartridgeSide view of 22 caliber long rifle ball cartridgeSide view of 22 caliber long rifle ball cartridgeSide view of 22 caliber long rifle ball cartridge" href="weaponLib/stillMedia/slides/A106.jpgweaponLib/stillMedia/slides/A106_A.jpgweaponLib/stillMedia/slides/A106_B.jpgweaponLib/stillMedia/slides/A106_C.jpgweaponLib/stillMedia/slides/A106_D.jpg" class="thumb"><img alt="Side view of 22 caliber long rifle ball cartridgeSide view of 22 caliber long rifle ball cartridgeSide view of 22 caliber long rifle ball cartridgeSide view of 22 caliber long rifle ball cartridgeSide view of 22 caliber long rifle ball cartridge" src="weaponLib/stillMedia/thumbs/A106.jpgweaponLib/stillMedia/thumbs/A106_A.jpgweaponLib/stillMedia/thumbs/A106_B.jpgweaponLib/stillMedia/thumbs/A106_C.jpgweaponLib/stillMedia/thumbs/A106_D.jpg"></a>

Within jqGrid, the cell is holding:

<td title="weaponLib/stillMedia/slides/A106.jpgweaponLib/stillMedia/slides/A106_A.jpgweaponLib/stillMedia/slides/A106_B.jpgweaponLib/stillMedia/slides/A106_C.jpgweaponLib/stillMedia/slides/A106_D.jpg" style="text-align: center; display: none;" role="gridcell">weaponLib/stillMedia/slides/A106.jpgweaponLib/stillMedia/slides/A106_A.jpgweaponLib/stillMedia/slides/A106_B.jpgweaponLib/stillMedia/slides/A106_C.jpgweaponLib/stillMedia/slides/A106_D.jpg</td>

I know that jqGrid is building it wrong. I am double-stumped as to what direction to take to fix it. Any suggestions would be greatly greatly appreciated.

A: 

it seems to me that the statemant

$('#thumbs ul').html('<li><a class='thumb' href='' + data.piclocation + '' title='' data.pictitle + ''><img src='" + data.picthumb  + "' alt='" + data.pictitle + "' /></a><div class='caption'><div class='image-title'>" + data.pictitle + "</div></div></li>");

inside of onSelectRow should be a little changed to use more " instead of ' (or you should use double '):

$('#thumbs ul').html("<li><a class='thumb' href='" +
                      data.piclocation + "' title='" + data.pictitle +
                      "'><img src='" + data.picthumb  +
                      "' alt='" + data.pictitle +
                  "' /></a><div class='caption'><div class='image-title'>" +
                   data.pictitle + "</div></div></li>");

you can see in the colors on stackoverflow.com that now everything look more correct.

Oleg
Oleg, Sorry for confusion. When I posted my question, I was lost on how to define script within my question. I had started to modify my script to get it to be viewed. then I found the proper way to get script embeded. My original script looks like your suggestion. when site only has to display 1 picture, the app works correctly. But when required to generate stacked <LI></LI>, it goes haywire. I have a version at http://www.serco-hrc.com/testMe/index.html. This should let ya see what is going on without me putting snapshots on this site. A085 (single pic) A106 (multi-pic) under
Energetic Pixels
the Small Arms menu item. Any suggestions/directions would be greatly appreciated.Tony
Energetic Pixels
Sorry, but I not really understand what you code should do. I could find `<DIV id=thumbs class=navigation><UL class="thumbs noscript"><LI><A class=thumb title="Side view of 22 caliber short blank cartridge" href="weaponLib/stillMedia/slides/A085.jpg"><IMG alt="Side view of 22 caliber short blank cartridge" src="weaponLib/stillMedia/thumbs/A085.jpg"></A><DIV class=caption><DIV class=image-title>Side view of 22 caliber short blank cartridge</DIV></DIV></LI></UL></DIV>` which I don't understand but it looks like correct. The main code which create jqGrid and some HTML I don't find.
Oleg