Kohana 3 JavaScript 问题
我们有一个简单的 JQuery 日期选择器,我们试图将其包含在页面上。该函数在海峡 html 网站上工作,但是,当我们通过 Kohana 包含工作函数时,该函数不起作用。我们尝试通过将所有 JavaScript 引用加载到模板中的数组中并使用打印它们来将其作为文件包含,
<?php foreach($scripts as $file) { echo HTML::script($file, NULL, TRUE), "\n"; }?>
以及简单地将脚本放在单独的视图中并使用 view::factory 来包含该文件。当我们执行后者时,浏览器无法识别 标记,或者至少其语法突出显示无法识别它,尽管这不会影响其他脚本(例如 Google 地图)。不管它的价值如何,它的功能如下:
jQuery(function(){
jQuery(".datepick").datepicker();
});
它所作用的元素是:
<input class="datepick" id="to" type="text" />
有人对我们有任何建议吗?我们非常渴望让这个简单的小功能发挥作用。
We have a simple JQuery date picker that we are trying to include on a page. The function works on a strait html site, however, when we include the working function via Kohana the function does not work. We have tried including it both as a file by loading all of the JavaScript references in an array in a template and printing them with
<?php foreach($scripts as $file) { echo HTML::script($file, NULL, TRUE), "\n"; }?>
As well as simply putting the script in a separate view and using view::factory to include the file. When we do the latter the </script>
tag is not recognized by browsers or at least its syntax highlighting is not picking it up, though this does not effect other scripts such as Google maps. For what ever it is worth, here is the function:
jQuery(function(){
jQuery(".datepick").datepicker();
});
and the element it is acting on is:
<input class="datepick" id="to" type="text" />
Does anyone have any suggestions for us. We are getting pretty desperate to make this one little simple function work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能不需要
HTML::script()
调用中的最后一个TRUE
,因为这会将index.php
添加到您的脚本中URL,暗示您正在使用 PHP 来提供实际的脚本文件。在这种情况下,我认为你的电话应该是:
You probably don't need the last
TRUE
on theHTML::script()
call, as that will addindex.php
to your script URL, implying that you are using PHP to serve the actual script files.In this case, I think your call should just be:
我认为这与 Kohana 无关,而是与您的 HTML 代码有关。
你如何包含你的脚本(jQuery 是否包含在你的 javascript 代码之前)?
I don't think this is related to Kohana but to your HTML code.
How do you include your scripts (is jQuery included before your javascript code) ?