如何在Impromptu回调中传递参数?
我使用 jQuery Impromptu 作为弹出窗口。原始代码如下:
function f1(pa1, pa2){
$.prompt("need to delete?",{
callback: callbackfunc,
button: {OK: true, Cancel: false}
});
}
function callbackfunc(v,m,f){
if(v){
// want to process the pa1 and pa2.
}
}
如何在回调中处理pa1
和pa2
?
I'm using jQuery Impromptu as a pop window. The raw code is as follow:
function f1(pa1, pa2){
$.prompt("need to delete?",{
callback: callbackfunc,
button: {OK: true, Cancel: false}
});
}
function callbackfunc(v,m,f){
if(v){
// want to process the pa1 and pa2.
}
}
How to process pa1
and pa2
inside the callback?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我在项目中使用你想要的东西。看看这个:
I use what you want in a project. See this:
我这样解决我的问题:
如果需要处理的参数较少就可以了。但是,如果回调函数过于复杂,参数较多,则此方法不太好。
我希望有人能给我更好的建议。
I solve my problem like this:
It's OK if there is less parameters to process. however, if the callback function is too complex, and there are much parameters, this method is a not good.
I hope somebody could give me a better suggestion.
如果回调方法上的代码变得复杂,最好的方法是:
If your code on the callback method is getting complex, the best way to do this is:
我不确定插件是否改变了这一点,或者某个地方有错误的文档,但是
callback
是submit
如今,它需要 4 个参数,而不是 3 个:event, value, message, formVals
:改编@Oytun Tez优秀答案,我已经做了这个例子:
I'm not sure if the plugin changed this or there was a wrong documentation somewhere, but the
callback
issubmit
nowadays and it takes 4 arguments instead of 3:event, value, message, formVals
:Adapting @Oytun Tez excelent answer, I've made this example: