1. <legend id='VgtyB'><style id='VgtyB'><dir id='VgtyB'><q id='VgtyB'></q></dir></style></legend>
        <bdo id='VgtyB'></bdo><ul id='VgtyB'></ul>

      <small id='VgtyB'></small><noframes id='VgtyB'>

      <i id='VgtyB'><tr id='VgtyB'><dt id='VgtyB'><q id='VgtyB'><span id='VgtyB'><b id='VgtyB'><form id='VgtyB'><ins id='VgtyB'></ins><ul id='VgtyB'></ul><sub id='VgtyB'></sub></form><legend id='VgtyB'></legend><bdo id='VgtyB'><pre id='VgtyB'><center id='VgtyB'></center></pre></bdo></b><th id='VgtyB'></th></span></q></dt></tr></i><div id='VgtyB'><tfoot id='VgtyB'></tfoot><dl id='VgtyB'><fieldset id='VgtyB'></fieldset></dl></div>
    2. <tfoot id='VgtyB'></tfoot>

        在 Drupal 7 中未调用 Javascript 函数,该函数曾经在 Drupal 6 中正常运行

        Javascript function not getting called in Drupal 7 which used to run proper in Drupal 6(在 Drupal 7 中未调用 Javascript 函数,该函数曾经在 Drupal 6 中正常运行)

          <tfoot id='Kz76j'></tfoot>

            <small id='Kz76j'></small><noframes id='Kz76j'>

            1. <legend id='Kz76j'><style id='Kz76j'><dir id='Kz76j'><q id='Kz76j'></q></dir></style></legend>
                  <tbody id='Kz76j'></tbody>
                  <bdo id='Kz76j'></bdo><ul id='Kz76j'></ul>

                • <i id='Kz76j'><tr id='Kz76j'><dt id='Kz76j'><q id='Kz76j'><span id='Kz76j'><b id='Kz76j'><form id='Kz76j'><ins id='Kz76j'></ins><ul id='Kz76j'></ul><sub id='Kz76j'></sub></form><legend id='Kz76j'></legend><bdo id='Kz76j'><pre id='Kz76j'><center id='Kz76j'></center></pre></bdo></b><th id='Kz76j'></th></span></q></dt></tr></i><div id='Kz76j'><tfoot id='Kz76j'></tfoot><dl id='Kz76j'><fieldset id='Kz76j'></fieldset></dl></div>
                  本文介绍了在 Drupal 7 中未调用 Javascript 函数,该函数曾经在 Drupal 6 中正常运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在将我的 Drupal 6 站点迁移到 Drupal 7.因此,我遇到了一些代码问题.在 Drupal 7 中调用带有 jquery 等的 javascript 是不同的,这是我读过的.这是我在 Drupal 6 中的页面图像.在更改下拉框时,它上面的表格会填充属于该列表的项目地位.这在 Drupal 6 中运行良好.但在 Drupal 7 中,我看到 这个 javascript 错误.

                  I am in the process of migrating my Drupal 6 site to Drupal 7. As a result i am facing some issues with the code. The calling of javascript laced with jquery etc is different in Drupal 7 is what i have read. This is the image of the page i had in Drupal 6. On change of the dropdown box, the table above it gets populated with projects belonging to that status. This works fine in Drupal 6. But in Drupal 7 i see this javascript error.

                  这是我的 php 文件中 Dropdown 的表单元素.

                  This is the form element for the Dropdown in my php file.

                  <? php
                   $form['status_list'] = array(
                  '#type' => 'select',
                  '#title' => t('Freeway Project Statuses'),
                  '#options' => array(
                    0 => t('-Select Status-'),
                    1 => t('Draft'),
                    2 => t('NotSpecified'),
                    3 => t('Quote'),
                    4 => t('Forecasted'),
                    5 => t('InEvaluation'),
                    6 => t('Cancelled'),
                    7 => t('Booked'),
                    8 => t('InProduction'),
                    9 => t('Completed'),
                    10 => t('Closed'),
                   ),
                   '#default_value' => array('0' => 'Select Status'),
                   '#weight' => 0,
                  );
                  

                  这就是 JavaScript我已经用 Drupal 7 的附加标签对其进行了修改

                  And this is the JavaScript I have modified it with the additional tags for Drupal 7

                   (function$){ .. })(jQuery); . 
                  

                  Drupal 6 中不需要这些标签.

                  These tags were not needed in Drupal 6.

                        (function$){
                      $(document).ready(function () {
                       $("#edit-status-list").change(function() {
                       var selectedStatus = $(this).find(":selected").text();
                       var charExists = ((window.location.href).indexOf('?') >= 0) ? true : false;
                  
                      if(charExists){
                      var split = (window.location.href).split('?');
                      var loc = split[0];
                  
                        loc = loc+"?status="+selectedStatus;  
                      self.location.href= loc;
                  
                      }
                  
                      else{
                       var locf = window.location.href+"?status="+selectedStatus;   
                       self.location.href= locf;
                  
                       }
                  
                       });
                  
                       $("#create-freeway-project").submit(function() {
                        $(":submit", this).attr("disabled", "disabled");
                  
                       });
                  
                      $(".common_link_class").click(function() {
                            //alert("Hello");
                  
                         var count = ($(this).data("clicks") || 0) + 1;
                         $(this).data("clicks", count);
                  
                  
                          if ($(this).data("clicks") >= 1) {
                  
                         }
                  
                  
                         if ($(this).data("clicks") >= 2) {
                  
                           return false;
                         }
                       });
                  
                  
                        $("#edit-analysis-code-one").change(function () {
                          // Get the configs and split them.
                          var cfgs = _get_configs("edit-custRef");
                          var split_cfgs = cfgs.split('/');
                  
                          // Create some new configs and put it back into the configs  textfield.
                          //var new_cfgs = $(this).val() +"/"+ cfgs[1];
                          var new_cfgs = $("#edit-analysis-code-one option:selected").text() +"/"+ cfgs[1];
                  
                          $("#edit-custRef").val(new_cfgs);
                        });
                  
                        $("#edit-analysis-code-two").change(function () {
                          // Get the configs and split them.
                          var cfgs = _get_configs("edit-custRef");
                          var split_cfgs = cfgs.split('/');
                  
                          // Create some new configs and put it back into the configs textfield.
                          //var new_cfgs = cfgs[0] +"/"+ $(this).val();
                          var new_cfgs = cfgs[0] +"/"+ $("#edit-analysis-code-two option:selected").text()
                          $("#edit-custRef").val(new_cfgs);
                       });
                  
                  
                     });
                  
                   })(jQuery); 
                  
                  
                  (function$){
                  function _get_configs(id) {
                  
                    return $("#"+ id).val();
                  
                  }   
                  })(jQuery); 
                  

                  #edit_status_list 是我们感兴趣的下拉菜单.

                  #edit_status_list is the dropdown of our interest.

                  希望您对在 Drupal 7 中正确调用 javascipt 需要做哪些额外更改提出建议

                  Would like to have your suggestions as to what additional change needs to be done for proper javascipt calling in Drupal 7

                  推荐答案

                  应该是

                  (function($) {
                  

                  没有

                  (function$ {
                  

                  你得到的是一个语法错误.第一个实例化一个函数,使其第一个参数可以通过其主体代码中的符号 $ 获得.函数在body之后调用:

                  What you've got is a syntax error. The first one instantiates a function such that its first argument will be available via the symbol $ in its body code. The function is invoked after the body:

                    // ...
                  })(jQuery);
                  

                  全局jQuery"对象作为参数传入.此设置可确保您的代码通过常见的$"符号访问正确的框架(即 jQuery),而不必担心$"的另一个外部绑定.

                  and the global "jQuery" object is passed in as the argument. This setup assures your code access to the correct framework (that is, to jQuery) via the common "$" symbol without having to worry about another external binding for "$".

                  这篇关于在 Drupal 7 中未调用 Javascript 函数,该函数曾经在 Drupal 6 中正常运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  Ordinals in words javascript(javascript中的序数)
                  getFullYear returns year before on first day of year(getFullYear 在一年的第一天返回前一年)
                  How do I make a TextGeometry multiline? How do I put it inside a square so it wraps like html text does inside a div?(如何制作 TextGeometry 多线?如何将它放在一个正方形内,以便它像 html 文本一样包裹在 div 内?) - IT屋-程序员软件开发技术分享社
                  How to use coffeescript in developing web-sites?(如何在开发网站时使用coffeescript?)
                      <legend id='mkhmt'><style id='mkhmt'><dir id='mkhmt'><q id='mkhmt'></q></dir></style></legend>

                    1. <i id='mkhmt'><tr id='mkhmt'><dt id='mkhmt'><q id='mkhmt'><span id='mkhmt'><b id='mkhmt'><form id='mkhmt'><ins id='mkhmt'></ins><ul id='mkhmt'></ul><sub id='mkhmt'></sub></form><legend id='mkhmt'></legend><bdo id='mkhmt'><pre id='mkhmt'><center id='mkhmt'></center></pre></bdo></b><th id='mkhmt'></th></span></q></dt></tr></i><div id='mkhmt'><tfoot id='mkhmt'></tfoot><dl id='mkhmt'><fieldset id='mkhmt'></fieldset></dl></div>

                          <tbody id='mkhmt'></tbody>
                          <bdo id='mkhmt'></bdo><ul id='mkhmt'></ul>
                            <tfoot id='mkhmt'></tfoot>

                          • <small id='mkhmt'></small><noframes id='mkhmt'>