【问题标题】:yii and jquery mobileyii 和 jquery 移动版
【发布时间】:2011-08-08 12:49:26
【问题描述】:

我在使用YiijQuery 手机时遇到问题。问题是jQuery mobile 仅使用来自rel="external" 链接的js 文件,这些文件位于带有data-role="page" 的div 内。 Yii 在 div 末尾或头部生成活动表单 js

我试着放了

<script src='lala/js.js' type = "text/javascipt"></script>

我可以将jscss 绑定到:

js.js:

$('div').live('pagebeforeshow', function(event, ui){
$("head").append("<link>");
    css = $("head").children(":last");
    css.attr({
      rel:  "stylesheet",
      type: "text/css",
      href: "/site/css/mobile/mobile.css"
    });
     $.getScript("/site/js/fancyForm_qe.js", function(){
         //some other stuff
     );
     });
   $('.successMessage').hide();
});

问题是我想使用Yii函数来添加css和js。 有什么解决办法吗?

【问题讨论】:

  • 你试过 Yii 的功能了吗(stackoverflow.com/questions/1998449/…)?不知道为什么你不能让这些工作。
  • 所以,那没用。我使用jquery mobile通过ajax获取的html,并手动解析它

标签: php jquery jquery-mobile mobile yii


【解决方案1】:

核心问题是 jquery mobile 不包含在页面 div 之外返回的任何内容。

解决方法是像往常一样使用 registerScript 等,然后 $markup = $this->render('view,$params,true,true);然后,您可以在 jquery 移动页面中回显完整的标记(带有脚本)。

PS:JQuery Mobile 中正在进行一些更改,删除了使用 div data-role=page 包装页面的要求。 Beta2 有这个,但好像有问题。

【讨论】:

  • Tnx,它引导我走向正确的方向:$markup = ''; Yii::app()-&gt;clientScript-&gt;render($markup); echo($markup);
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-05
  • 2011-09-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-16
相关资源
最近更新 更多