属性'$'的对象(Property '$' of object)
我有一个Wordpress网站,最终是一个流媒体广播网站。 在标题我有一个脚本,从我的专用服务器的CP拉动流数据(如听众计数和当前正在播放)..(Centova演员)
我在function.php中注册了脚本:
这是登记册
wp_register_script('streaminfo','http://94.23.250.14:2199/system/streaminfo.js',false,null); wp_enqueue_script('streaminfo');
这是整个jQuery部分供您查看..
/* ------------------------------------ :: INITIATE JQUERY / STYLING ------------------------------------ */ function init_dynscripts() { if (!is_admin()) { if ( function_exists('bp_is_blog_page')) { if (!bp_is_blog_page()) { wp_enqueue_script( 'bp-js', BP_PLUGIN_URL . '/bp-themes/bp-default/_inc/global.js', array( 'jquery' ) ); } } wp_register_style('northvantage-style', get_bloginfo('stylesheet_url'),false,null); wp_enqueue_style('northvantage-style'); if(get_option('enable_responsive')!='disable') : wp_register_style('northvantage-responsive', get_template_directory_uri().'/stylesheets/responsive.css',false,null); wp_enqueue_style('northvantage-responsive'); endif; wp_enqueue_script('jquery-ui-core',false,null); wp_enqueue_script('jquery-ui-tabs',false,null); wp_enqueue_script("jquery-ui-accordion",false,null); wp_enqueue_script("swfobject",false,null); wp_deregister_script("jquery-effects-core"); wp_deregister_script('libertas'); wp_register_script('libertas',get_template_directory_uri().'/js/nv-script.pack.js',false,null); wp_enqueue_script('libertas'); wp_register_script( ’streaminfo’, 'http://94.23.250.14:2199/system/streaminfo.js',false,null); wp_enqueue_script( ’streaminfo’ ); wp_register_script( ’jpie’, get_template_directory_uri().'/js/jpie.js',false,null); wp_enqueue_script( ’jpie’ ); wp_register_style('jpiestyle', get_template_directory_uri().'/jpie.css',false,null); wp_enqueue_style('jpiestyle'); if(get_option('jwplayer_js')) { // Check jw player javascript file is present $NV_jwplayer_js = get_option('jwplayer_js'); wp_deregister_script( 'jw-player' ); wp_register_script( 'jw-player', $NV_jwplayer_js,false,null); wp_enqueue_script( 'jw-player' ); } } } add_action('init', 'init_dynscripts',100); function _remove_script_version( $src ){ // remove script version $parts = explode( '?', $src ); return $parts[0]; } add_filter( 'script_loader_src', '_remove_script_version', 15, 1 ); add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
看来我在streaminfo.js和我的网站之间有冲突。 元素检验给出:
未捕获的TypeError:对象[对象窗口]的属性'$'不是函数
简而言之......我尝试使用该文件的所有内容都错了。
我尝试将每个$符号更改为文件中的jQuery,它消除了冲突,但与其他文件产生冲突。
我尝试添加
jQuery(document).ready(function($){
到文件的头部,但它打破了CP上的其他元素。
最后,我运行了一个简单的测试并创建了一个只包含以下代码的网页:
<html> <body> <span id="cc_strinfo_title_tranceilfm" class="cc_streaminfo"></span> <script language="javascript" type="text/javascript" src="http://94.23.250.14:2199/system/streaminfo.js"></script> </body> </html>
并且页面没有返回任何错误。 (我确实包含了google jQuery文件的路径)
Wordpress中的东西搞砸了jQuery插件? 或者我的代码中缺少一些字符串?
www.tranceil.fm
I have a Wordpress website which eventually is a streaming radio website. on the header i have a script that is pulling streaming data (like listeners count and currently playing) from my Dedicated server's CP..(Centova Cast)
I registered the script in the function.php:
this is the register
wp_register_script( ’streaminfo’, 'http://94.23.250.14:2199/system/streaminfo.js',false,null); wp_enqueue_script( ’streaminfo’ );
This is the the whole jQuery section for you to review..
/* ------------------------------------ :: INITIATE JQUERY / STYLING ------------------------------------ */ function init_dynscripts() { if (!is_admin()) { if ( function_exists('bp_is_blog_page')) { if (!bp_is_blog_page()) { wp_enqueue_script( 'bp-js', BP_PLUGIN_URL . '/bp-themes/bp-default/_inc/global.js', array( 'jquery' ) ); } } wp_register_style('northvantage-style', get_bloginfo('stylesheet_url'),false,null); wp_enqueue_style('northvantage-style'); if(get_option('enable_responsive')!='disable') : wp_register_style('northvantage-responsive', get_template_directory_uri().'/stylesheets/responsive.css',false,null); wp_enqueue_style('northvantage-responsive'); endif; wp_enqueue_script('jquery-ui-core',false,null); wp_enqueue_script('jquery-ui-tabs',false,null); wp_enqueue_script("jquery-ui-accordion",false,null); wp_enqueue_script("swfobject",false,null); wp_deregister_script("jquery-effects-core"); wp_deregister_script('libertas'); wp_register_script('libertas',get_template_directory_uri().'/js/nv-script.pack.js',false,null); wp_enqueue_script('libertas'); wp_register_script( ’streaminfo’, 'http://94.23.250.14:2199/system/streaminfo.js',false,null); wp_enqueue_script( ’streaminfo’ ); wp_register_script( ’jpie’, get_template_directory_uri().'/js/jpie.js',false,null); wp_enqueue_script( ’jpie’ ); wp_register_style('jpiestyle', get_template_directory_uri().'/jpie.css',false,null); wp_enqueue_style('jpiestyle'); if(get_option('jwplayer_js')) { // Check jw player javascript file is present $NV_jwplayer_js = get_option('jwplayer_js'); wp_deregister_script( 'jw-player' ); wp_register_script( 'jw-player', $NV_jwplayer_js,false,null); wp_enqueue_script( 'jw-player' ); } } } add_action('init', 'init_dynscripts',100); function _remove_script_version( $src ){ // remove script version $parts = explode( '?', $src ); return $parts[0]; } add_filter( 'script_loader_src', '_remove_script_version', 15, 1 ); add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
It appears i have a conflict between streaminfo.js and my website. element inspection gives:
Uncaught TypeError: Property '$' of object [object Window] is not a function
To make things short..everything i tried with the file ended up wrong.
i tried changing every $ sign to jQuery in the file, it eliminate the conflict but created conflicts with other files.
i tried adding
jQuery(document).ready(function ($) {
to the head of the file but it breaks other elements on the CP.
Eventually i ran a simple test and created a webpage with only this code:
<html> <body> <span id="cc_strinfo_title_tranceilfm" class="cc_streaminfo"></span> <script language="javascript" type="text/javascript" src="http://94.23.250.14:2199/system/streaminfo.js"></script> </body> </html>
And the page didn't return any errors. (i did include a path to the google jQuery file)
Something in Wordpress is messing up with the jQuery plugin? or some string is missing in my code?
www.tranceil.fm
原文:https://stackoverflow.com/questions/11764154
满意答案
您无法对
list
的元素进行ref
,更改ref
,然后期望list
的项目发生更改。 如果您真的想这样做,那么您应该将引用放入Tree
类型中。type Tree = |Node of string*list<Tree ref> |Empty let rec branchToTree (inputList:list<string>) = match inputList with | [] -> Tree.Empty | head::tail -> Tree.Node(head, [ref (branchToTree tail)])
如果你这样做,删除
List.map (fun(child) -> ref child)
部分,然后你的代码就可以了。您可能对拉链感兴趣,它允许您做类似但没有变异的事情。
You can't make a
ref
to an element in alist
, change theref
and then expect the item in thelist
to change. If you really want to do that then you should put the references into yourTree
type.type Tree = |Node of string*list<Tree ref> |Empty let rec branchToTree (inputList:list<string>) = match inputList with | [] -> Tree.Empty | head::tail -> Tree.Node(head, [ref (branchToTree tail)])
If you do that, remove the
List.map (fun(child) -> ref child)
part then your code works.You might be interested in zippers which allow you to do something similar but without mutation.
相关问答
更多使用F#实现树构建器(Implement tree builder with F#)
是否有F#活动的建设者?(Is there a builder for F# events?)
F#树:节点插入(F# Tree: Node Insertion)
f#访问树的根元素(f# access root element of a tree)
如何在F#中的二叉搜索树中实现添加操作?(How to implement add operation in Binary Search Tree in F#?)
编译F#报价:性能?(Compiling an F# quotation: performance?)
将JSON多路树解码为F#多路树识别联盟(Decode JSON Multiway Tree into an F# Multiway Tree Discriminated Union)
Rx的F#工作流构建器(F# workflow builder for Rx)
相关文章
更多Guava学习笔记:复写的Object常用方法
Cannot expose request attribute 'website' because of an existing model object of the same name 的解决方案
Object Oriented Programming
java通用返回对象
could not find system property or JNDI
不显示删除回复显示所有回复显示星级回复显示得分回复 请问java Object的hashcode()方法是怎么实现的啊,内部的算法是什么啊
关于对象复制时出现内容不一致的问题
Storm【设计细节】 -Fields对象
关于两种对象类型使用
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!