使用 jquery 选择器获取 uibinder 元素在 chrome/safari 上失败

发布于 2024-09-16 12:25:58 字数 999 浏览 7 评论 0原文

我有像下面这样的uibinder html元素,

       <g:HTMLPanel>
  <div class='thumbnailWrapper'>
     <ul>
         <li>
             <a href='#'><img src='41546-140.jpg' /></a>
             <div class='caption'>
                 <p class='captionInside'>testing javascript</p>
             </div>
         </li>
         <div class='clear'></div><!-- clear the float -->
     </ul><!-- end unordered list -->
</div><!-- end spolightWrapper div -->

<script>
jQ_Zoom();
</script>

        </g:HTMLPanel>

我的javascript在firefox中执行没有问题,即。但在野生动物园/ chrome,javascript不被调用。看看我上传的样本 在 http://bit.ly/ayuFc1 。尝试用firefox打开并比较 chrome/safari

我的 javascript

function jQ_Zoom(){

      alert('yoyo');    

alert($('.thumbnailWrapper ul li').find('img').height());

}

i have uibinder html element like below

       <g:HTMLPanel>
  <div class='thumbnailWrapper'>
     <ul>
         <li>
             <a href='#'><img src='41546-140.jpg' /></a>
             <div class='caption'>
                 <p class='captionInside'>testing javascript</p>
             </div>
         </li>
         <div class='clear'></div><!-- clear the float -->
     </ul><!-- end unordered list -->
</div><!-- end spolightWrapper div -->

<script>
jQ_Zoom();
</script>

        </g:HTMLPanel>

my javascript have no problem executed in firefox,ie. but in safari/
chrome, the javascript is not call. have a look at my uploaded sample
at http://bit.ly/ayuFc1 . try open with firefox and compared with
chrome/safari

my javascript

function jQ_Zoom(){

      alert('yoyo');    

alert($('.thumbnailWrapper ul li').find('img').height());

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我不会写诗 2024-09-23 12:25:58

看起来您将

  1. 将 Javascript 函数包装在 JSNI 调用中
  2. 在 HTML 文件中进行 Javascript

第一个选项是将本机 Javascript 与 GWT 集成的首选方法。

It looks like you are putting the <script> tag directly in your UiBinder xml, that doesn't look right. I think the correct solution is either:

  1. Wrap the Javascript function in a JSNI call.
  2. Make your Javascript <script> call in your HTML file (outside of the UiBinder).

The first option is the preferred method of integrating native Javascript with GWT.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文