简体   繁体   English

jQuery BlockUI错误

[英]Error with jquery BlockUI

I've used this plugin many times, in very much the same manner as seen here, and yet my latest implementation is not working. 我已经多次使用此插件,其方式与此处看到的方式几乎相同,但是我最新的实现无法正常工作。

Here is the JavaScript: 这是JavaScript:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/jquery.blockUI.js" type="text/javascript"></script>
<script type="text/javascript">
   function disableButtons(){
        alert('TEST'); //this is here just to see if the function is called
        $('div.blockbutton').block({
            message: '<h4>Saving...</h4>',
            css: { border: '2px solid orange' }
         });
     }
</script>

And the HTML: 和HTML:

<div align="center" class="blockbutton">
    <input name="save" type="button" class="btn6022" value="Save" 
       onClick=disableButtons();
         <c:if test='${(sessionScope.package != "NWR")}'>                        
       saveConfirm1(onset_date,report_date,lost_consciousness_date,fatal_death_date);">
         </c:if>
         <c:if test='${(sessionScope.package == "NWR")}'>                        
       "saveConfirm2(onset_date,report_date,fatal_death_date);">
          </c:if>
     </div>

Here is what my Firebug console is giving me when triggering the function: TypeError: $(...).block is not a function [Break On This Error] 这是我的Firebug控制台在触发函数时给我的信息:TypeError:$(...)。block不是一个函数[中断此错误]

css: { border: '2px solid orange' } CSS:{边框:“ 2像素纯橙色”}

I'm baffled since this code is identical to what I have done on other pages, without fail. 我很困惑,因为这段代码与我在其他页面上所做的完全相同。 Can someone spot a problem here I'm missing? 有人可以在这里找到我所缺少的问题吗?

I see some inconsistencies within your <c:if> blocks. 我在您的<c:if>块中看到了一些不一致之处。 The bottom one wraps saveConfirm2 in double quotes. 最下面的一个将saveConfirm2用双引号引起来。 The top one only has a double quote at the end after saveConfirm. saveConfirm之后,最上面的一个在结尾处带有双引号。 Even without that issue, it's not completely clear what you are trying to do, so just take a look at the rendered HTML to make sure it makes sense. 即使没有这个问题,也不清楚您要做什么,因此只需查看呈现的HTML即可确保它有意义。 Also, I'm not familiar, but it looks to be JSP from a quick search. 另外,我也不熟悉,但是通过快速搜索它看起来像是JSP。 In that case, the <c:if> blocks are just for conditional rendering. 在这种情况下, <c:if>块仅用于条件渲染。 The content inside those blocks should end in /> to close the <input node. 这些块中的内容应以/>结尾,以关闭<input节点。 In order to close the node correctly and for both of your functions to get called onClick, you need to have the modifications below. 为了正确关闭节点并使两个函数都调用onClick,您需要进行以下修改。 I made the onClick start with a double quote. 我用双引号使onClick开始。 Then the content in the c:if blocks closes the initial opening quote and closes the 然后,c:if块中的内容将关闭开头的引号并关闭

   onClick="disableButtons();
     <c:if test='${(sessionScope.package != "NWR")}'>                        
   saveConfirm1(onset_date,report_date,lost_consciousness_date,fatal_death_date);" />
     </c:if>
     <c:if test='${(sessionScope.package == "NWR")}'>                        
   saveConfirm2(onset_date,report_date,fatal_death_date);" />
      </c:if>

I think you were seeing the javascript errors due to malformed HTML. 我认为您由于HTML格式错误而看到了JavaScript错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM