Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript函数在Drupal7中没有被调用,而Drupal7在Drupal6中正常运行_Javascript_Jquery_Drupal 7 - Fatal编程技术网

Javascript函数在Drupal7中没有被调用,而Drupal7在Drupal6中正常运行

Javascript函数在Drupal7中没有被调用,而Drupal7在Drupal6中正常运行,javascript,jquery,drupal-7,Javascript,Jquery,Drupal 7,我正在将我的Drupal6站点迁移到Drupal7。因此,我在代码方面面临一些问题。 在Drupal7中,调用带有jquery等的javascript是不同的,这是我读到的。 更改下拉框时,上面的表将填充属于该下拉框的项目 地位这在Drupal6中运行良好。 但是在Drupal7中我看到了 这是我的php文件中下拉列表的表单元素 <? php $form['status_list'] = array( '#type' => 'select', '#title' => t('F

我正在将我的Drupal6站点迁移到Drupal7。因此,我在代码方面面临一些问题。 在Drupal7中,调用带有jquery等的javascript是不同的,这是我读到的。 更改下拉框时,上面的表将填充属于该下拉框的项目 地位这在Drupal6中运行良好。 但是在Drupal7中我看到了

这是我的php文件中下拉列表的表单元素

<? 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,
);
Drupal6中不需要这些标签

      (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); 
#编辑状态列表
是我们感兴趣的下拉列表

我想听听您的建议,对于Drupal 7中正确的javascipt调用,还需要做哪些额外的更改

(function($) {
不是

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

  // ...
})(jQuery);

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

谢谢。javascript引发错误的错误由此得以解决。但是Jquery方法没有反映出这一点。我也会提出一个新问题。嗨,我想听听你对我这个相关问题的看法
(function$ {
  // ...
})(jQuery);