jQuery mobile适用于所有玉器文件(Node,Express)

时间:2016-08-22 12:43:53

标签: node.js express jquery-mobile

我有一个如下所示的玉文件:

home.jade

        html
            head
                title= title
                link(rel='stylesheet', href='/stylesheets/style.css')
                link(rel='stylesheet', href='http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css')
                script(src='http://code.jquery.com/jquery-1.11.3.min.js')
                script(src='http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js')
            body
                block content
                ...

                li
                    a(href='/documents', class='text-center') Add Document

它包括jquery mobile css和js。当我按照 home.jade 中的链接到任何其他jade文件时,它会自动选择jquery移动脚本,即使它们没有包含在其他jade文件中。

例如,当我点击"添加文件"链接它将我带到 documents.jade ,如下所示:

documents.jade

doctype html
html
    head
        title= title
        link(rel='stylesheet', href='/stylesheets/style.css')
        body
        ...

但是当我检查元素时,它附加了jquery移动类:

<html class="ui-mobile">

当我只刷新页面时,移动类就会消失。 有人知道为什么会这样吗?

1 个答案:

答案 0 :(得分:0)

嗯,这就是我设法做到的方式(不是最优雅的方式,但它有效..)

home.jade 我把它放在头部:

$(document).on("mobileinit", function () {
   $.mobile.ignoreContentEnabled=true;
});

在所有其他玉文件中我把它放在body标签之后:

script.
    $(document).bind('pageinit', function(event){
        $('.ui-link').removeClass('ui-link');
    });

我已将这行代码放在我不希望jquery mobile生效的所有地方:

(data-enhance="false")