按下按钮之后,如果f.alertName == ""(就是表单中的alertName为空),则an.css("border","solid #ff0000 1px")(操作m--弹窗内容中的表单,把其变成红色),最后return false,取消表单关闭。
var statesdemo = {
state0: {
html:'test 1.<br />test 1..<br />test 1...',
buttons: { Cancel: false, Next: true },
focus: 1,
submit:function(e,v,m,f){
if(!v) return true;
else
$.prompt.goToState('state1');
return false;
}
},
state1: {
html:'test 2',
buttons: { Back: -1, Exit: 0 },
focus: 1,
submit:function(e,v,m,f){
else if(v=-1)
if(v==0) $.prompt.close()
$.prompt.goToState('state0');
return false;
}
}
};
$.prompt(statesdemo);
点击Next会进入下一个state,这里关键代码是$.prompt.goToState('state0'),跳到指定的state。但是,记得在后面return false取消弹窗的消失。
var tourSubmitFunc = function(e,v,m,f){
if(v === -1){
$.prompt.prevState();
return false;
}
else if(v === 1){
$.prompt.nextState();
return false;
}
},
tourStates = [
{
html: 'Welcome to jQuery Impromptu, lets take a quick tour of the plugin.',
buttons: { Next: 1 },
focus: 1,
position: { container: '#header', x: 10, y: 45, width: 200, arrow: 'tl' },
submit: tourSubmitFunc
},
{
html: 'When you get ready to use Impromptu, you can get it here.',
buttons: { Prev: -1, Next: 1 },
focus: 1,
position: { container: '#downloadHeader', x: 170, y: -10, width: 300, arrow: 'lt' },
submit: tourSubmitFunc
},
{
html: "You will also need this CSS",
buttons: { Prev: -1, Next: 1 },
focus: 1,
position: { container: '#cssHeader', x: 40, y: -100, width: 250, arrow: 'bl' },
submit: tourSubmitFunc
},
{
html: 'A description of the options are under the Docs section.',
buttons: { Prev: -1, Next: 1 },
focus: 1,
position: { container: '#docsHeader', x: 115, y: -85, width: 200, arrow: 'lb' },
submit: tourSubmitFunc
},
{
html: 'You will find plenty of examples to get you going.. including this tour..',
buttons: { Prev: -1, Next: 1 },
focus: 1,
position: { container: '#examplesHeader', x: -300, y: -45, width: 250, arrow: 'rm' },
submit: tourSubmitFunc
},
{
html: 'Yep, see, creating a tour is easy.. Here is the source:',
buttons: { Prev: -1, Next: 1 },
focus: 1,
position: { container: '#tourExample', x: -340, y: 5, width: 300, arrow: 'rt' },
submit: tourSubmitFunc
},
{
html: 'This concludes our tour. If you found Impromptu helpful, please see the links to the left, if not, thanks for stopping by!',
buttons: { Done: 2 },
focus: 1,
position: { container: '#donationHeader', x: 420, y: 0, width: 300, arrow: 'lm' },
submit: tourSubmitFunc
}
];
$.prompt(tourStates, { opacity: 0.3 });
其实这个是state的变体,给states加上position属性。用$.prompt.prevState()和$.prompt.nextState()来在states间跳转。