使用jQuery Mobile和jQuery Steps

时间:2014-02-03 02:28:00

标签: jquery jquery-mobile jquery-steps

我希望为应用程序表单创建前端,以便显示&导航为多步向导。

我已经使用jQuery Mobile 1.4.0构建了一个单独的垂直HTML页面,并且已经非常好地工作了。

然后我添加了jQuery Steps 1.0.4来集成向导方面并保持了大部分的外观。不幸的是,大多数表单字段的jQuery Mobile功能已停止工作。例如,滑块不拖动,文本框不突出显示。没有JS错误,这些字段最初正确显示,只是表现不正常。

我想知道是否有人曾经使用这两个库,找到了解决方法,或者对如何集成这两个库有任何建议。

<body>
<div id="main">
    <form id="" action="landing.html">
        <div id="wizard">
            <h1>Step 2 - Heading</h1>
            <div id="step_2">
                <section>
                    <fieldset data-role="controlgroup" data-type="horizontal">
                        <legend>Radio Options</legend>
                        <input type="radio" name="radio-choice-1" id="radio-choice-1" value="choice-1" />
                        <label for="radio-choice-1">Option 1</label>
                        <input type="radio" name="radio-choice-1" id="radio-choice-2" value="choice-2" />
                        <label for="radio-choice-2">Option 2</label>
                        <input type="radio" name="radio-choice-1" id="radio-choice-3" value="choice-3" />
                        <label for="radio-choice-3">Option 3</label>
                    </fieldset>
                </section>
            </div>
        </div>
    </form>
</div>

<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js" type="text/javascript"></script>
<script src="scripts/libs/jquery.steps-1.0.4.js"></script>
<script src="scripts/initiate.wizard.js"></script>

1 个答案:

答案 0 :(得分:1)

我发现了答案。根据jQuery Step的问题解决方案的作者:

https://github.com/rstaib/jquery-steps/issues/31

我不得不推迟jQuery Mobile的自动启动,直到jQuery Steps完成所需的一切。

<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script>window.jQuery || document.write('<script src="scripts/libs/jquery-1.10.2.min.js"><\/script>')</script>
<script src="scripts/libs/jquery.steps-1.0.4.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.min.js"></script>
<script>jQuery.ui || document.write('<script src="scripts/libs/jquery-ui-1.10.4.min.js"><\/script>')</script>
<script>
    // delay jQuery Mobile initialisation to allow jQuery Steps initialise first
    $(document).on("mobileinit", function () {
        $.mobile.autoInitializePage = false;
    });
</script>
<script src="http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js" type="text/javascript"></script>
<script>$.mobile || document.write('<script src="scripts/libs/jquery.mobile-1.4.0.min.js"><\/script>')</script>
<script src="scripts/initiate.wizard.js"></script>
<script>
    // now the DOM should be ready to handle the jQuery Mobile initialisation
    $(document).ready(function () {
        $.mobile.initializePage();
    });
</script>
<script src="scripts/scripts.js"></script>