简体   繁体   English

MVC4中的bxSlider和引导程序

[英]bxSlider and bootstrap in MVC4

I have a asp.net mvc4 project and i use bootstrap template. 我有一个asp.net mvc4项目,我使用引导模板。 So far so good, but also I need to use BxSlider. 到目前为止,还不错,但是我还需要使用BxSlider。

I was used BxSlider before in MVC without any problem, so may be the conflict is with bootstrap. 我以前在MVC中使用BxSlider时没有任何问题,所以可能与引导程序冲突。

I receive error : Uncaught TypeError: Object [object Object] has no method 'bxSlider' 我收到错误:未捕获的TypeError:对象[object Object]没有方法'bxSlider'

on this line : 在这条线上:

$('.bxslider').bxSlider({

Everything else work correct, i don`t have jquery conflicts or etc. 其他一切工作正常,我没有jquery冲突等。

I would appreciate any help .. thanks in advance .. 我将不胜感激..在此先感谢..

The mentioned error refers to 2 possible mistakes: 提到的错误涉及2个可能的错误:

  1. undefined jquery before named library, say BxSlider. 未命名的jQuery在命名库之前说BxSlider。
  2. Undefined named library after jquery library. jQuery库之后未定义的命名库。

Note that These types of errors are more possible in Microsoft MVC Architecture, because of availability of section definitions or partial uses, and in one phrase, more Programmer tools to work easier! 请注意,由于提供了节定义或部分使用的信息,因此在Microsoft MVC体系结构中更可能出现这些类型的错误,并且总而言之, 更多的Programmer工具可以更轻松地工作! So be careful in case of calling js libraries in such tools in Microsoft MVC. 因此,在Microsoft MVC中的此类工具中调用js库时要小心。 I suggest you to trace/track related view from main layout (perhaps _Layout.cshtml ) until complete view to be rendered. 我建议您从主布局(也许是_Layout.cshtml )跟踪/跟踪相关视图,直到呈现完整视图为止。 You can use some techniques like required : false to avoid multiple resource calls in RenderSection too. 您可以使用诸如required : false类的技术来避免在RenderSection调用多个资源。

Thank for all ideas .. found a solution.. 谢谢所有的想法..找到了一个解决方案..

I was add bxslider lib in top of my View.. after that i call init script for bgSlider(again in this view file). 我在视图顶部添加了bxslider lib。之后,我调用了bgSlider的初始化脚本(再次在该视图文件中)。

Now i move out load of lib in bottom in master layout view and after it load init and now it`s work. 现在,我在主布局视图的底部移出了lib的负载,在它加载init之后,现在可以正常工作了。

Honestly i don`t see what is the problem here .. In this view i loaded already other Js libs and they work correctly. 老实说,我看不出这里有什么问题..在这种情况下,我已经加载了其他Js库,它们可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM