jquery-steps内容是否有限制?

时间:2014-07-10 04:57:19

标签: jquery jquery-steps

我正在使用jquery步骤向用户显示一个表单,但是我遇到了一个与内容属性有点奇怪的问题。

如果我在一行代码中同时拥有" ",则步骤可行。

但是,如果我通过添加另一个输入字段将结束"移动到另一行,则不会渲染步骤。

$("#wizard").steps({
    headerTag: "h3",
    bodyTag: "fieldset",
    transitionEffect: "slideLeft",
    onStepChanging: function(event, currentIndex, newIndex) {

    //only apply to first step

    if (currentIndex === 0 && ($("#workType > option:selected").val()) === "1") {

        $("#wizard").steps("insert", 1, {
            title: "Construction Details",
            content: "<input type='text' name='budget' id='budget' placeholder='What is your budget?'><br/>"
        });
    }
});

所以这有效:

content: "<input type='text' name='budget' id='budget' placeholder='What is your budget?'><br/>"

这不是:

 content: "<input type='text' name='budget' id='budget' placeholder='What is your budget?'>
           <input type='text' name='timeline' id='timeline' placeholder='When do you want to start?'>
                            <br/>"

内容是否需要全部放在一行或我做错了什么? TIA

1 个答案:

答案 0 :(得分:2)

您可以尝试使用+连接字符串,例如:

content: "<input type='text' name='budget' id='budget' placeholder='What is your budget?'>" + 
           "<input type='text' name='timeline' id='timeline' placeholder='When do you want to start?'> +
           "<br/>";

或其他方式:

var content_str = [
    '<input type='text' name='budget' id='budget' placeholder='What is your budget?'>',
    '<input type='text' name='timeline' id='timeline' placeholder='When do you want to start?'>',
    '<br />'
].join('');
...
contnet: content_str