0

这是原剧本...

$j(document).ready(function() { 
    //Show and hide the Loading icon on Ajax start/end

    $j('.bwbps_uploadform').submit(function() { 
        $j('#bwbps_message').html('');
        bwbpsAjaxLoadImage(this);
        return false; 
    });

    //make sure the upload form radio button is on Select file
    $j(".init_radio").attr("checked","checked");
        //Add OnClick to the Mass Update Buttons in the PhotoSmash Settings form
        if ($j('#bwbps_gen_settingsform').val() == '1') {
            bwbpsAddPSSettingsMassUpdateActions();
        }
        $j('.bwbps-post-cat-form').attr('multiple','multiple');
    }   
});

我想更改此脚本以在另一个函数中调用它,但是 firebug 中存在语法错误:

var myFunction;
$j(document).ready(function() { 
    //Show and hide the Loading icon on Ajax start/end
    myFunction = function() {
        $j('.bwbps_uploadform').submit(function() { 
            $j('#bwbps_message').html('');
            bwbpsAjaxLoadImage(this);
            return false; 
        });

        //make sure the upload form radio button is on Select file
        $j(".init_radio").attr("checked","checked");

        //Add OnClick to the Mass Update Buttons in the PhotoSmash Settings form
        if ($j('#bwbps_gen_settingsform').val() == '1') {
            bwbpsAddPSSettingsMassUpdateActions();
        }
        $j('.bwbps-post-cat-form').attr('multiple','multiple');
    }   
});

怎么了?有谁能够帮我??

var $j = jQuery.noConflict();

感谢您的帮助!

4

1 回答 1

0

像这样使用:

 var myFunction;
 $j(document).ready(function() { 
  //Show and hide the Loading icon on Ajax start/end
  myFunction = function($j) {
    $j('.bwbps_uploadform').submit(function() { 
        $j('#bwbps_message').html('');
        bwbpsAjaxLoadImage(this);
        return false; 
    });

    //make sure the upload form radio button is on Select file
    $j(".init_radio").attr("checked","checked");

    //Add OnClick to the Mass Update Buttons in the PhotoSmash Settings form
    if ($j('#bwbps_gen_settingsform').val() == '1') {
        bwbpsAddPSSettingsMassUpdateActions();
    }
    $j('.bwbps-post-cat-form').attr('multiple','multiple');
   }   
 });

在 myFunction 中传递 $j 作为参数

于 2013-09-09T12:07:20.960 回答