Jquery 即兴
我在将 Jquery Impromptu 框添加到我的项目中时遇到了一些问题。该代码在项目外部运行良好,但放在项目内部时会出现故障。
<script type="text/javascript">
function openprompt(){
var txt = 'Text here';
function mycallbackform(v,m,f){
if(v != undefined)
$.prompt(v +' ' + f.alertName);
}
$.prompt(txt,{
callback: mycallbackform,
buttons: { Add: 'add', Cancel: 'cancel' }
});
}
</script>
执行时该函数不会执行任何操作。如果我删除 $.prompt 那么它就会起作用。
当我执行该函数时,我也收到此控制台消息...
Uncaught TypeError: Object function ( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init( selector, context, rootjQuery );
} has no method 'prompt'
代码放置在 PHP 文件中,我认为这可能会导致问题,但我已经在另一个 PHP 文件中测试了代码,所以它不仅仅是 PHP 。
我计划使用提示来显示组合框,这就是我无法使用标准警报的原因。
我对这些事情很陌生,我做错了什么吗?
谢谢
I've been having some trouble adding Jquery Impromptu boxes into a project of mine. The code works fine outside of the project, but when placed inside malfunctions.
<script type="text/javascript">
function openprompt(){
var txt = 'Text here';
function mycallbackform(v,m,f){
if(v != undefined)
$.prompt(v +' ' + f.alertName);
}
$.prompt(txt,{
callback: mycallbackform,
buttons: { Add: 'add', Cancel: 'cancel' }
});
}
</script>
When executed this function will do nothing. If I remove the $.prompt then it will work.
I'm also getting this console message when I execute the function...
Uncaught TypeError: Object function ( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init( selector, context, rootjQuery );
} has no method 'prompt'
The code is placed in a PHP file which I think might be causing the problem, but I have tested the code in another PHP file, so its not the PHP alone.
I am planning to use the prompt to display a combo-box which is why I can't use a standard alert.
I'm quite new to these things, am i doing anything obviously wrong?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您在该项目之外使用此代码时,您是否扩展了 jQuery 方法?如果是,您应该在该项目中包含 jquery 的扩展。
$.prompt 这意味着,在你的 jquery 库中有一个方法名称提示。
如果“否”,则您的项目 jQuery 库与您测试此代码的项目外部不同。必须有一个方法(函数)名称提示,并且您必须将其包含在您的项目中。
Have you extended the jQuery methods when you used this code out side this project? If yes you should include that extension of jquery in this project.
$.prompt this means, in your jquery library there is a method name prompt.
If NO, your jQuery library of project is not same with Out side the project where you have tested this code. There must be a method (function) name prompt and you have to include that in your project.