문제

in html with jade

link(rel="stylesheet",href="/stylesheets/index/index.css")
script(src="/javascripts/assets/jquery_loader.js")
script(src="/javascripts/assets/bootstrap/bootstrap.js")

im using modernizr to load zepto or jquery if IE is the browser

Modernizr.load(
{
    test: /(msie) ([\w.]+)/.test(navigator.userAgent),
    yep: '/javascripts/assets/jquery/jquery-1.9.1.min.js',
    nope: '/javascripts/assets/zepto/zepto.min.js',
    complete:function()
    {
        if(!window.jQuery)
        {
            Zepto.browser = {webkit: true}
            window.jQuery = Zepto
        }
    }
});

i receive this error

Uncaught TypeError: undefined is not a function 
(anonymous function) bootstrap.js:60

on line :60

}(window.jQuery);

i try to load bootstrap with modernizr

Modernizr.load(
{
    test: /(msie) ([\w.]+)/.test(navigator.userAgent),
    yep: ['/javascripts/assets/jquery/jquery-1.9.1.min.js','/javascripts/assets/bootstrap/bootstrap.js'],
    nope: ['/javascripts/assets/zepto/zepto.min.js','/javascripts/assets/bootstrap/bootstrap.js'],
    complete:function()
    {
        if(!window.jQuery)
        {
            Zepto.browser = {webkit: true}
            window.jQuery = Zepto
        }
    }
});

and the error disapear but bootstrap doesnt work so i test in console

typeof $().modal == 'function'

and the result is 'false', this means that bootstrap doesnt download from server

how can i solve this?? tnx

도움이 되었습니까?

해결책

i solve the problem using this script, tnx all!

Modernizr.load(
{
    test: /MSIE ([0-9]{1,}[\.0-9]{0,})/.test(navigator.userAgent),
    yep: '/javascripts/assets/jquery/jquery-1.9.1.min.js',
    nope: '/javascripts/assets/zepto/zepto.min.js',
    complete:function()
    {
        if(!window.jQuery)
        {
            Zepto.browser = {webkit: true}
            window.jQuery = Zepto
            console.log('Zepto')
        }
        Modernizr.load(
        {
            load:'/javascripts/assets/bootstrap/bootstrap.js',
            complete:function()
            {
                console.log('Loaded!')
            },
        })
    },
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top