开发者

Play! framefork renders incorrectly arguments from a controller to a view

开发者 https://www.devze.com 2023-04-04 05:56 出处:网络
My controller action: public static void showGalery() { ... render(subPhotos, size); } A part of my view: <img id=\"mainImage\"

My controller action:

public static void showGalery() {
    ...
    render(subPhotos, size);
}

A part of my view:

<img id="mainImage" 
     src="${subPhotos.get(0).path}" 
     class="galery-main-photo" 
     onmouseover="toolTip(${subPhotos.get(0).description});"
     onmouseout="toolTip();" />

Path passed correcly from an action, but description incorrectly (javascript function doesn't call). If I write ${subPhotos.get(0).d开发者_如何转开发escription.length()} then Javascript function are called and passed a correct length of a string. From DB got a correct description.

Thanks, Sergey


Because the description is a string, you must surround it with quotes. Be sure to use single quotes, because the HTML attribute is using double quotes.

onmouseover="toolTip('${subPhotos.get(0).description}');"
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号