Jquery临时回调问题- $.提示失败
Jquery Impromptu Callback issue - $.prompt fails
我有一个jQuery即兴的问题,特别是$。提示内联表单的回调函数
现在,实际的具体问题如下。如果提交时email_address
字段是空白的,我无法让$.prompt('Please supply an email address for the customer')
工作,但是如果我将其更改为alert('Please supply an email address for the customer')
,它将工作。
我猜这是一个范围问题,因为其他$.prompt
调用按预期工作,我认为是因为它们在$.post
回调函数内。
我一直在努力寻找回调表单功能的大量文档,虽然我觉得我了解e
, v
和f
变量,但m
(消息)不是我以前使用过的东西。当我将m
记录到控制台日志时,它看起来像jQuery即兴对象,但是我不确定如何访问它的属性。我已经尝试了m.prompt()
和$.m.prompt()
,但这些只是猜测我将如何访问prompt
功能。
var txt = '<input type="text" name="email_address" value="" />';
function mycallbackform(e,v,m,f)
{
if(v != undefined)
{
if (v == true)
{
console.log(f);
if (f.email_address.length == 0)
{
console.log(m);
$.prompt('Please supply an email address for the customer');
}
else
{
$.post('". $this->view->url(array(), 'admin-create-user-from-checkout') ."', f, function(data) {
if(data.status)
{
$.prompt('Customer Record Created Successfully');
}
else
{
$.prompt('Customer Record could not be created');
$('#email_address').val($('#old_email_address').val());
}
}, 'json');
}
}
else
{
$('#email_address').val($('#old_email_address').val());
}
}
$.prompt(txt,{callback: mycallbackform, buttons: { Ok: true, Cancel: false }});
m
控制台日志
Object[div.jqimessage]
0
div.jqimessage
context
undefined
jquery
"1.7.2"
length
1
prevObject
Object[div#jqi_state_state0.jqi_state]
selector
".children(#jqi) #jqi_st...0.children(.jqimessage)"
constructor
function()
init
function()
_toggle
function()
add
function()
addClass
function()
affix
function()
after
function()
ajaxComplete
function()
ajaxError
function()
ajaxSend
function()
ajaxStart
function()
ajaxStop
function()
ajaxSuccess
function()
alert
function()
andSelf
function()
animate
function()
append
function()
appendTo
function()
attr
function()
before
function()
bind
function()
blur
function()
button
function()
carousel
function()
change
function()
children
function()
clearQueue
function()
click
function()
clone
function()
closest
function()
collapse
function()
contents
function()
contextmenu
function()
css
function()
data
function()
dblclick
function()
delay
function()
delegate
function()
dequeue
function()
detach
function()
die
function()
domManip
function()
dropdown
function()
each
function()
empty
function()
end
function()
eq
function()
error
function()
extend
function()
fadeIn
function()
fadeOut
function()
fadeTo
function()
fadeToggle
function()
filter
function()
find
function()
first
function()
focus
function()
focusin
function()
focusout
function()
get
function()
has
function()
hasClass
function()
height
function()
hide
function()
hover
function()
html
function()
index
function()
innerHeight
function()
innerWidth
function()
insertAfter
function()
insertBefore
function()
is
function()
keydown
function()
keypress
function()
keyup
function()
last
function()
live
function()
load
function()
map
function()
modal
function()
mousedown
function()
mouseenter
function()
mouseleave
function()
mousemove
function()
mouseout
function()
mouseover
function()
mouseup
function()
next
function()
nextAll
function()
nextUntil
function()
not
function()
off
function()
offset
function()
offsetParent
function()
on
function()
one
function()
outerHeight
function()
outerWidth
function()
parent
function()
parents
function()
parentsUntil
function()
popover
function()
position
function()
prepend
function()
prependTo
function()
prev
function()
prevAll
function()
prevUntil
function()
promise
function()
prompt
function()
promptDropIn
function()
prop
function()
push
push()
pushStack
function()
queue
function()
ready
function()
remove
function()
removeAttr
function()
removeClass
function()
removeData
function()
removeProp
function()
replaceAll
function()
replaceWith
function()
resize
function()
revmaxslide
function()
revnext
function()
revolution
function()
revpause
function()
revprev
function()
revresume
function()
revshowslide
function()
scroll
function()
scrollLeft
function()
scrollTop
function()
scrollspy
function()
select
function()
serialize
function()
serializeArray
function()
show
function()
siblings
function()
size
function()
slice
function()
slideDown
function()
slideToggle
function()
slideUp
function()
sort
sort()
splice
splice()
stop
function()
submit
function()
swipe
function()
tab
function()
text
function()
toArray
function()
toggle
function()
toggleClass
function()
tooltip
function()
transit
function()
transition
function()
trigger
function()
triggerHandler
function()
typeahead
function()
unbind
function()
undelegate
function()
unload
function()
unwrap
function()
val
function()
waitForImages
function()
width
function()
wrap
function()
wrapAll
function()
wrapInner
function()
__proto__
Object[]
问题解决!
@link: https://github.com/trentrichardson/jQuery-Impromptu/issues/6
"
在新的事件系统中,回调被绑定到提示符上。所以callback必须在提示符被销毁之前调用。即兴表演不适合同时出现多个提示。如果你想解决这个问题,一个简单的解决方案是setTimeout(10, function(){$.prompt(…);}); 在回调函数内部。这将为之前的提示符提供关闭的机会。
固定Javascriptvar txt = '<input type="text" name="email_address" value="" />';
function mycallbackform(e,v,m,f)
{
if(v != undefined)
{
if (v == true)
{
if (f.email_address.length == 0)
{
setTimeout(function(){ $.prompt('Please supply an email address for the customer'); }, 10);
}
else
{
$.post('". $this->view->url(array(), 'admin-create-user-from-checkout') ."', f, function(data) {
if(data.status)
{
$.prompt('Customer Record Created Successfully');
}
else
{
$.prompt('Customer Record could not be created');
$('#email_address').val($('#old_email_address').val());
}
}, 'json');
}
}
else
{
$('#email_address').val($('#old_email_address').val());
}
}
$.prompt(txt,{callback: mycallbackform, buttons: { Ok: true, Cancel: false }});
相关文章:
- 提示使用服务器端事件处理程序激活JavaScript
- 当json解析空响应时,Whatwg-Fetch失败,我该如何防止它
- d3.js Chord图的动态工具提示
- Javascript 可选类型提示
- JsFiddle在分叉后描述失败
- 单击按钮后启动javascript提示
- Graphiti中是否有任何工具提示功能
- JS,用于播放提示音以通知未按预期工作
- "工具提示"jQuery插件坏了
- 如何在 JavaScript 和 HTML 中更改对输入框的提示响应
- 单元格的工具提示或标题不显示超过2000个字符
- JQM simpledialog:如何提示输入数字
- d3.js用按钮更新条形图工具提示
- Jquery临时回调问题- $.提示失败
- Grunt失败,提示“无法找到模块”.对于本地模块
- beforeDelete函数失败,提示“成功/未调用错误”
- Javascript提示在一次尝试后失败
- 如果文本框验证失败,如何在该文本框上放置引导工具提示
- Youtube iframe API加载或提示播放列表失败
- 这个表单提示“发送失败”