亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

jWiard 基于JQuery的強(qiáng)大的向?qū)Э丶榻B

 更新時(shí)間:2011年10月28日 22:45:23   作者:  
jWiard 基于JQuery的強(qiáng)大的向?qū)Э丶榻B,需要的朋友可以參考下。

我就不貼我現(xiàn)在做項(xiàng)目的代碼,我直接把作者的示例搬過(guò)來(lái),因?yàn)楦膭?dòng)不大,只要做點(diǎn)修改,就能很好的滿足我們自己的需求。

原文地址 猛點(diǎn)這里下載      

作者官網(wǎng)   不過(guò)是英文的,英語(yǔ)好的話 可以看原文,生怕我表達(dá)錯(cuò)誤。

不知道童鞋們?cè)谄綍r(shí)的開(kāi)發(fā)用到用向?qū)介_(kāi)發(fā)這種方式?jīng)]有?有人問(wèn) 什么是向?qū)介_(kāi)發(fā)呢?其實(shí),很簡(jiǎn)單,就是讓用戶完成一個(gè)步驟,然后點(diǎn)擊下一步,完成一個(gè)步驟就點(diǎn)擊下一步,這樣 按照我?guī)煾傅膩?lái)說(shuō),可以很好的提升用戶體驗(yàn)。

OK,廢話不說(shuō)了,先來(lái)一個(gè)最簡(jiǎn)單的例子:
例子1:
1.1當(dāng)然咯,既然是JQuery 就少不了需要引用JQuery庫(kù)吧。在上面就能下到相關(guān)的類(lèi)庫(kù)。
JQuery Class and Style

復(fù)制代碼 代碼如下:

<!-- jquery ui theme -->
<link rel="stylesheet" href="/path/to/jquery-ui.css" />
<!-- required CSS basics -->
<link rel="stylesheet" href="/path/to/jWizard.base.css" />
<!-- duh -->
<script type="text/javascript" src="/path/to/jquery.js"></script>
<!-- at least the widget factory -->
<script type="text/javascript" src="/path/to/jquery-ui.js"></script>
<!-- and the plugin itself -->
<script type="text/javascript" src="/path/to/jWizard.min.js"></script>

1.2 然后就開(kāi)始寫(xiě) HTML代碼了,也很簡(jiǎn)單。
HTML Code
復(fù)制代碼 代碼如下:

<form id="wizard-form" class="jWizard">
<fieldset>
<legend>Beginning</legend>
<p>Are you sure you want to begin? Press "Next" to proceed?</p>
</fieldset>
<fieldset>
<legend>Middle</legend>
<p>Are you sure you want to?</p>
<p>You can still go back. Or press "Next" again to confirm.</p>
</fieldset>
<fieldset>
<legend>End</legend>
<p>Done, click "Finish" to end</p>
</fieldset>
</form>
<!-- Can also just be divs with title attributes -->
<div id="wizard-div" class="jWizard">
<div title="Beginning">
<p>Are you sure you want to begin? Press "Next" to proceed?</p>
</div>
<div title="Middle">
<p>Are you sure you want to?</p>
<p>You can still go back. Or press "Next" again to confirm.</p>
</div>
<div title="End">
<p>Done, click "Finish" to end</p>
</div>
</div>

你可以在上面的HTML代碼了 進(jìn)行添加相關(guān)的div,不過(guò) 可別忘記了給最外面的賦上title值哦。
1.3 js開(kāi)始調(diào)用。
JS Call
復(fù)制代碼 代碼如下:

$(".jWizard").jWizard({
menuEnable: true,
counter: {
enable: true,
progressbar: true
},
effects: { enable: true }
});

OK, 到此為止,上面的基本步驟就實(shí)現(xiàn)了,效果如下:


示例 2:給next添加事件
在我現(xiàn)在做的第一個(gè)版本里,剛開(kāi)始比如有上傳文件,驗(yàn)證文件等等操作,很二的直接在頁(yè)面放了一個(gè)button,然后觸發(fā)它的javascript代碼。這樣做可以滿足基本功能的需求,可是也非常嚴(yán)重的損害了用戶的體驗(yàn)。因?yàn)?,現(xiàn)在的用戶非常的懶,能少做一點(diǎn)事情,它是絕對(duì)不會(huì)多做的。所以,如果你放一個(gè)button,用戶不想去點(diǎn)擊,然后就點(diǎn)擊next了,那么就得不到需要的用戶,就會(huì)報(bào)錯(cuò)。
因此,我們可以把一些操作都集成到Next中去,那這樣子就灰?;页5姆奖懔?,而且頁(yè)面也變的灰?;页5恼麧嵈蠓?。
其余代碼可以基本不變,現(xiàn)在我主要講一下js里面的事件機(jī)制,代碼如下:

復(fù)制代碼 代碼如下:

var $w = $("#events-test");
$w.validate({ errorClass: "ui-state-error-text" });
$w
.jWizard({
buttons: {
cancelType: "reset", // 點(diǎn)擊”Cancel“按鈕的時(shí)候 觸發(fā)的動(dòng)作,比如我在項(xiàng)目中,是跳到第一頁(yè) 重新開(kāi)始。
finishType: "submit" // 在最后一步點(diǎn)擊”finish“的時(shí)候,出發(fā)的動(dòng)作,也就是提交。
},
// 點(diǎn)擊”Cancel“按鈕的時(shí)候 觸發(fā)的動(dòng)作,比如我在項(xiàng)目中,是跳到第一頁(yè) 重新開(kāi)始。
cancel: function(event, ui) {
$w.jWizard("firstStep");
},      // 點(diǎn)擊previous的時(shí)候觸發(fā)的動(dòng)作。比如在我項(xiàng)目中,因?yàn)楫?dāng)把所有的郵件都發(fā)送完畢的時(shí)候,就不能讓用戶上一頁(yè)了,所以我要把上一頁(yè)的功能給進(jìn)禁止掉。很簡(jiǎn)單,如下;
previous: function(event, ui) {
// if(ui.currentStepIndex==7){return false;} 就可以了。7 指的是你的div的順序數(shù)字,從0開(kāi)始,哈這個(gè)會(huì)數(shù)吧。
},
next: function(event, ui) {
// 這里同理哦,就是控制下一頁(yè)的情況,也是上面一樣。比如,在我項(xiàng)目中,有一個(gè)上傳數(shù)據(jù)的,要是沒(méi)有就不能讓它上傳。這種情況 你可以先設(shè)定一個(gè)bool值,然后,
if(fileUploadComplete){ $.get("@Url.Action("VerificationSchema", "Home")", // 這里學(xué)習(xí)MVC的童鞋們應(yīng)該很熟悉 其實(shí)也就是在action home 下面的方法 VerificationSchema function (data) { // 獲取成功后返回的數(shù)據(jù) var newData = eval(data); // 因?yàn)橛玫膉son 所以用eval 進(jìn)行轉(zhuǎn)換 schemaVerification=newData.HasErrors; if(newData.HasErrors) { var listing1 = document.getElementById("listing1"); listing1.innerHTML = "<font color='red' size='20px'>Congruations.Please go on.</font>"; } else { document.getElementById("ErrorNotification").innerHTML="Sorry.Your Schema wrong,please check it."; var listing1 = document.getElementById("listing1"); listing1.innerHTML = newData.Result; } },"json");} else { //這里主要是當(dāng)沒(méi)有選擇數(shù)據(jù)的時(shí)候 進(jìn)行提示 alert("Please firstly Upload the Excel File you need"); return false; } break; },
finish: function(event, ui) {
alert("Thank you!");
}
})
/** The bindings below are event handlers, they will all be executed before proceeding to the callback */
/** ui = {
type: "previous|next|first|last|manual",
currentStepIndex: [int],
nextStepIndex: [int]
}; */
// This event handler is specifically used for form validation
.bind("jwizardchangestep", function (event, ui) {
// "manual" is always triggered by the user, never jWizard itself
if (ui.type !== "manual") {
var $currentStep = $w.find(".jw-step:eq(" + ui.currentStepIndex + ")"),
$inputs = $currentStep.find("input:text");
/** I am assuming you have `jquery.validate.js` running in this callback */
if ($inputs.length > 0 && !$inputs.valid()) {
$currentStep.find("label.error").effect("highlight");
return false;
}
}
})
// This event handler is for handling custom navigation through the wizard
.bind("jwizardchangestep", function (event, ui) {
// "manual" is always triggered by the user, never jWizard itself
if (ui.type !== "manual") {
// 這里其實(shí)是比較重要的,因?yàn)檫@里就是選擇對(duì)應(yīng)div的實(shí)現(xiàn)方式的,你只需要把相應(yīng)模塊的javascript代碼集成到這里就可以了。
switch (ui.currentStepIndex) {
// on the first step, the user must agree to the terms and conditions
case 0:
if ($("#agree").is(":not(:checked)")) {
// use this effect to give the user feedback
$("#agree").parent().effect("pulsate");
return false;
}
break;
// on the 3rd step, (zero-index) the username being filled means we are skipping the openid step
case 2:
if ($("#username").val() != "") {
// by setting this value on the event object, I am telling jWizard to override the nextStepIndex
event.nextStepIndex = 4;
// you must at least call event.preventDefault(); in order for this to work
return false;
}
break;
}
}
// by using nextStepIndex, we can intercept the user when they are *about to start* on a particular step
switch (ui.nextStepIndex) {
// in this case, I am displaying a summary on the last step of the wizard
case 4:
var oFormValues = {
name: $("#name").val(),
email: $("#email").val(),
username: $("#username").val(),
openid: undefined
};
$("#summary-name").children("td").text(oFormValues.name);
$("#summary-email").children("td").text(oFormValues.email);
if (oFormValues.username != "") {
$("#summary-username").show().children("td").text(oFormValues.username);
$("#summary-openid").hide().children("td").text("");
} else {
var $openid = $w.find("input:radio:checked[name=openid]");
oFormValues.openid = ($openid.length === 1) ? $openid.val() : $("#openid-other").val();
$("#summary-username").hide().children("td").text("");
$("#summary-openid").show().children("td").text(oFormValues.openid);
}
break;
}
});
// if the user clicks the openid link on step 3, (zero-index) cause the wizard to jump to the openid step
$("#openid").click(function () {
$w.jWizard("changeStep", 3);
return false;
});
// if an openid radio button is checked, blank out the `other` textbox
$w.find("input:radio[name=openid]").change(function (event) {
$("#openid-other").val("");
});
// if the `other` openid textbox is used, blank out the radio buttons
$("#openid-other").change(function (event) {
if (this.value != "") {
$w.find("input:radio[name=openid]").removeAttr("checked");
}
});

sum,我的搜狗怎么突然就沒(méi)有用了。
算了 以上就是我的一點(diǎn)點(diǎn)經(jīng)驗(yàn),就不說(shuō)了,吃飯時(shí)間到了,如果有需要的童鞋在做開(kāi)發(fā)的時(shí)候,如果遇到問(wèn)題,可以進(jìn)行共同討論,呵呵 共同進(jìn)步嘛。

具體效果在這里 。

相關(guān)文章

最新評(píng)論