0

js の wordpress テンプレートのテーマ オプションに問題があります。Ajaxアップロードの問題だと思います。コードは次のとおりです。

ほとんどのブラウザをチェックインしましたが、すべてのブラウザで同じ問題が発生しました。テンプレートの作成者も応答していません。

     <script>
    //AJAX Upload
    function of_image_upload_builder() {
    jQuery('.image_upload_button').each(function(){

    var clickedObject = jQuery(this);
    var clickedID = jQuery(this).attr('id');    

    var nonce = jQuery('#security').val();

    new AjaxUpload(clickedID, {
        action: ajaxurl,
        name: clickedID, // File upload name
        data: { // Additional data to send
            action: 'of_ajax_post_action',
            type: 'upload',
            security: nonce,
            data: clickedID },
        autoSubmit: true, // Submit file after selection
        responseType: false,
        onChange: function(file, extension){},
        onSubmit: function(file, extension){
            clickedObject.text('Uploading'); // change button text, when user selects file  
            this.disable(); // If you want to allow uploading only 1 file at time, you can disable upload button
            interval = window.setInterval(function(){
                var text = clickedObject.text();
                if (text.length < 13){  clickedObject.text(text + '.'); }
                else { clickedObject.text('Uploading'); } 
                }, 200);
        },
        onComplete: function(file, response) {
            window.clearInterval(interval);
            clickedObject.text('Upload Image'); 
            this.enable(); // enable upload button


            // If nonce fails
            if(response==-1){
                var fail_popup = jQuery('#of-popup-fail');
                fail_popup.fadeIn();
                window.setTimeout(function(){
                fail_popup.fadeOut();                        
                }, 2000);
            }               

            // If there was an error
            else if(response.search('Upload Error') > -1){
                var buildReturn = '<span class="upload-error">' + response + '</span>';
                jQuery(".upload-error").remove();
                clickedObject.parent().after(buildReturn);

                }
            else{
                var buildReturn = '<img class="hide of-option-image" id="image_'+clickedID+'" src="'+response+'" alt="" />';

                jQuery(".upload-error").remove();
                jQuery("#image_" + clickedID).remove(); 
                clickedObject.parent().after(buildReturn);
                $('img#image_'+clickedID).fadeIn();
                clickedObject.next('span').fadeIn();
                clickedObject.parent().prev('input').val(response);
            }
        }
    });

    });

    }
        //Add new slide
jQuery(document).ready(function() {
    jQuery(".builderslide_add_button").click(function() {   
    var slidesContainer = jQuery(this).prev();
    var sliderId = slidesContainer.attr('id');
    var sliderInt = jQuery('#'+sliderId).attr('rel');

    var numArr = jQuery('#'+sliderId +' li').find('.order').map(function() { 
        var str = this.id; 
        str = str.replace(/\D/g,'');
        str = parseFloat(str);
        return str;         
    }).get();

    var maxNum = Math.max.apply(Math, numArr);
    if (maxNum < 1 ) { maxNum = 0};
    var newNum = maxNum + 1;

    var newSlide = '<li class="temphide"><div class="slide_header"><strong>Box ' + newNum + '</strong><input type="hidden" class="slide of-input order" name="' + sliderId + '[' + newNum + '][order]" id="' + sliderId + '_slide_order-' + newNum + '" value="' + newNum + '"><a class="slide_edit_button" href="#">Edit</a></div><div class="slide_body" style="display: none; "><label>Title</label><input class="slide of-input of-slider-title" name="' + sliderId + '[' + newNum + '][title]" id="' + sliderId + '_' + newNum + '_slide_title" value=""><label>Type</label><select class="select of-input" name="' + sliderId + '[' + newNum + '][type]" id="' + sliderId + '_' + newNum + '_slide_type">';

            var newSlide = newSlide + '<option value="cat_news">News Box</option>';                             var newSlide = newSlide + '<option value="video_show">Video Show</option>';                             var newSlide = newSlide + '<option value="blog_style">Blog Style Box</option>';                             var newSlide = newSlide + '<option value="car_style">Carousel Box</option>';                            
    var newSlide = newSlide + '</select><label>Category</label><select class="select of-input" name="' + sliderId + '[' + newNum + '][cat]" id="' + sliderId + '_' + newNum + '_slide_cat">';

            var newSlide = newSlide + '<option value="0">All</option>';                             var newSlide = newSlide + '<option value="22">Blogs</option>';                              var newSlide = newSlide + '<option value="14">Interviews</option>';                             var newSlide = newSlide + '<option value="3">Mira's Daily MMA</option>';                                var newSlide = newSlide + '<option value="1">News</option>';                                var newSlide = newSlide + '<option value="398">Podcast Feed</option>';                              var newSlide = newSlide + '<option value="259">Uncategorized</option>';                             var newSlide = newSlide + '<option value="1673">Video Feed</option>';                               var newSlide = newSlide + '<option value="7">Videos</option>';                          
    var newSlide = newSlide + '</select><label>Tags (Seperate them by comma, example tag1, tag2)</label><input class="slide of-input of-slider-tags" name="' + sliderId + '[' + newNum + '][tags]" id="' + sliderId + '_' + newNum + '_slide_tags" value=""><label>Number</label><input class="slide of-input of-slider-number" name="' + sliderId + '[' + newNum + '][number]" id="' + sliderId + '_' + newNum + '_slide_number" value=""><a class="slide_delete_button" href="#">Delete</a><div class="clear"></div></div></li>';

    slidesContainer.append(newSlide);
    jQuery('.temphide').fadeIn('fast', function() {
        jQuery(this).removeClass('temphide');
    });

    of_image_upload_builder(); // re-initialise upload image..

    return false; //prevent jumps, as always..
});

});
</script>   

キャッチされていない構文エラーの取得エラー: の識別されていない識別子:

 var newSlide = newSlide + '<option value="0">All</option>';                                var newSlide = newSlide + '<option value="22">Blogs</option>';                              var newSlide = newSlide + '<option value="14">Interviews</option>';                             var newSlide = newSlide + '<option value="3">Mira's Daily MMA</option>';                                var newSlide = newSlide + '<option value="1">News</option>';                                var newSlide = newSlide + '<option value="398">Podcast Feed</option>';                              var newSlide = newSlide + '<option value="259">Uncategorized</option>';                             var newSlide = newSlide + '<option value="1673">Video Feed</option>';                               var newSlide = newSlide + '<option value="7">Videos</option>';

var newSlide = newSlide + '</select><label>Tags (Seperate them by comma, example tag1, tag2)</label><input class="slide of-input of-slider-tags" name="' + sliderId + '[' + newNum + '][tags]" id="' + sliderId + '_' + newNum + '_slide_tags" value=""><label>Number</label><input class="slide of-input of-slider-number" name="' + sliderId + '[' + newNum + '][number]" id="' + sliderId + '_' + newNum + '_slide_number" value=""><a class="slide_delete_button" href="#">Delete</a><div class="clear"></div></div></li>';
4

1 に答える 1

0

newSlide識別子は、キーワードが再利用されるたびにリセットされるため、すべてundefined:var

var newSlide = newSlide + ...

ステートメントは

newSlide = newSlide + "";

var初期化は次のようにする必要があります。

var clickedObject = jQuery(this);
var clickedID = jQuery(this).attr('id');    
var newSlide = "";
var nonce = jQuery('#security').val();
于 2013-11-01T22:30:00.190 に答える