首页 \ 问答 \ 属性'$'的对象(Property '$' of object)

属性'$'的对象(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.

相关问答

更多
  • 您无法对list的元素进行ref ,更改ref ,然后期望list的项目发生更改。 如果您真的想这样做,那么您应该将引用放入Tree类型中。 type Tree = |Node of string*list |Empty let rec branchToTree (inputList:list) = match inputList with | [] -> Tree.Empty | head::tail -> T ...
  • 托马斯在这里做了一些研究 ,这似乎是一个富有成效的途径。 Tomas has done some research here, and this does seem a fruitful avenue.
  • 在您的评论之后,这里的代码将按预期运行: 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 pers ...
  • 这个怎么样: 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 is emp ...
  • 您收到错误是因为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#慢50倍,甚至比天真的翻译慢。 坦率地说,我不明白他们为什么不将F#编译器本身暴露为运行时服务(和FSI)。 如果他们做了F#,他们现在会有更好的工具...... 编辑:我昨晚对运行斐波那契函数的报价进行了基准测试,实际上是700倍! Last I looked, the performance was absolutely awful, around 50× slower than F# and even slower than a naive interpreter. Fr ...
  • 考虑这一点的一种方法是查看构建CommentMultiTreeDatabaseModel 。 它需要CommentDatabaseModel和CommentMultiTreeDatabaseModel列表。 所以我们需要编写以下两个函数: let parseComment (input : JSON) : CommentDatabaseModel = ... let parseTree (input : JSON) : CommentMultiTreeDatabaseModel = ... ...
  • 首先,需要针对最新的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 (xs, ...

相关文章

更多

最新问答

更多
  • 如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
  • linux的常用命令干什么用的
  • 由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)
  • 如何交换返回集中的行?(How to swap rows in a return set?)
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • 使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)
  • Java中的不可变类(Immutable class in Java)
  • WordPress发布查询(WordPress post query)
  • 如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)
  • 是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)
  • GEP分段错误LLVM C ++ API(GEP segmentation fault LLVM C++ API)
  • 绑定属性设置器未被调用(Bound Property Setter not getting Called)
  • linux ubuntu14.04版没有那个文件或目录
  • 如何使用JSF EL表达式在param中迭代变量(How to iterate over variable in param using JSF EL expression)
  • 是否有可能在WPF中的一个单独的进程中隔离一些控件?(Is it possible to isolate some controls in a separate process in WPF?)
  • 使用Python 2.7的MSI安装的默认安装目录是什么?(What is the default installation directory with an MSI install of Python 2.7?)
  • 寻求多次出现的表达式(Seeking for more than one occurrence of an expression)
  • ckeditor config.protectedSource不适用于editor.insertHtml上的html元素属性(ckeditor config.protectedSource dont work for html element attributes on editor.insertHtml)
  • linux只知道文件名,不知道在哪个目录,怎么找到文件所在目录
  • Actionscript:检查字符串是否包含域或子域(Actionscript: check if string contains domain or subdomain)
  • 将CouchDB与AJAX一起使用是否安全?(Is it safe to use CouchDB with AJAX?)
  • 懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
  • 使用hasclass为多个div与一个按钮问题(using hasclass for multiple divs with one button Problems)
  • Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)
  • 无法在新线程中从FREContext调用getActivity()?(Can't call getActivity() from FREContext in a new thread?)
  • 在Alpine上升级到postgres96(/ usr / bin / pg_dump:没有这样的文件或目录)(Upgrade to postgres96 on Alpine (/usr/bin/pg_dump: No such file or directory))
  • 如何按部门显示报告(How to display a report by Department wise)
  • Facebook墙贴在需要访问令牌密钥后无法正常工作(Facebook wall post not working after access token key required)
  • Javascript - 如何在不擦除输入的情况下更改标签的innerText(Javascript - how to change innerText of label while not wiping out the input)
  • WooCommerce / WordPress - 不显示具有特定标题的产品(WooCommerce/WordPress - Products with specific titles are not displayed)