属性'$'的对象(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
2022-07-06 19:07

满意答案

您无法对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 a list, change the ref and then expect the item in the list to change. If you really want to do that then you should put the references into your Tree 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#)

您无法对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 ...

是否有F#活动的建设者?(Is there a builder for F# events?)

托马斯在这里做了一些研究 ,这似乎是一个富有成效的途径。 Tomas has done some research here, and this does seem a fruitful avenue.

F#树:节点插入(F# Tree: Node Insertion)

在您的评论之后,这里的代码将按预期运行: let insert pntName (Person(_, newPrsnYear, _) as newPrsn) (Person (n,y,ch)) = let rec ins n y = function | [] -> if y < newPrsnYear && n = pntName then Some [newPrsn] else None | (Person (name, year, childs) as...

f#访问树的根元素(f# access root element of a tree)

这个怎么样: let rootValue (Node(_,v,_)) = v 如果树为空,这将抛出异常。 或者: let tryGetRootValue = function | Node(_,v,_) -> Some v | _ -> None 这将始终成功,但将返回float option而不是float 。 How about this: let rootValue (Node(_,v,_)) = v This will throw an exception if the tree i...

如何在F#中的二叉搜索树中实现添加操作?(How to implement add operation in Binary Search Tree in F#?)

您收到错误是因为None匹配返回Some Node ,因此您必须在所有其他分支中匹配该返回类型。 您可以通过在匹配后返回节点来解决其他匹配中的问题: let rec Add (node:Node option) value = match node with | None -> Some { Left = None; Right = None; Value = value; Count = 1 } | Some t -> match t with ...

编译F#报价:性能?(Compiling an F# quotation: performance?)

最后我看,表现非常糟糕,比F#慢50倍,甚至比天真的翻译慢。 坦率地说,我不明白他们为什么不将F#编译器本身暴露为运行时服务(和FSI)。 如果他们做了F#,他们现在会有更好的工具...... 编辑:我昨晚对运行斐波那契函数的报价进行了基准测试,实际上是700倍! Last I looked, the performance was absolutely awful, around 50× slower than F# and even slower than a naive interprete...

将JSON多路树解码为F#多路树识别联盟(Decode JSON Multiway Tree into an F# Multiway Tree Discriminated Union)

考虑这一点的一种方法是查看构建CommentMultiTreeDatabaseModel 。 它需要CommentDatabaseModel和CommentMultiTreeDatabaseModel列表。 所以我们需要编写以下两个函数: let parseComment (input : JSON) : CommentDatabaseModel = ... let parseTree (input : JSON) : CommentMultiTreeDatabaseModel = ...

Rx的F#工作流构建器(F# workflow builder for Rx)

首先,需要针对最新的Rx版本稍微更新原始代码。 也就是说, For和While应该实现为: member this.For (xs : 'a seq, f: 'a -> 'b IObservable) = Observable.SelectMany(xs.ToObservable(), new Func<_, IObservable<_>>(f)) member this.While (f, xs: 'a IObservable) = Observable.TakeWhile ...

相关文章

更多

Guava学习笔记:复写的Object常用方法

  在Java中Object类是所有类的父类,其中有几个需要override的方法比如equals,h ...

Cannot expose request attribute 'website' because of an existing model object of the same name 的解决方案

在使用springmvc+freemarker,有可能你会遇到以下异常(如:资源找不到重定向到404的 ...

Object Oriented Programming

Some might also contend that inheritance should be ...

java通用返回对象

java通用返回对象返回对象通常包括是否成功、响应码、接口响应描述、响应实体几个属性

could not find system property or JNDI

Thanks everyone!! Finally got a solution for this p ...

关于对象复制时出现内容不一致的问题

Object.extend=function(a,b){ for(k in b){ alert(k ...

Storm【设计细节】 -Fields对象

本章主题: 记录一个小小的Tips 1 Storm在Emit publicclassValuesext ...

关于两种对象类型使用

直接描述的我的问题了。 我的需求是读取本地或异地的数据,程序中用到ResultSet(本地读取)和D ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本