WORDPRESS错误:未捕获的TypeError:无法读取未定义的属性“替换”

时间:2018-08-28 20:00:33

标签: javascript jquery html wordpress

我正在编辑我的wordpress页面,但没有做任何异常操作,但是突然我的Homepage失去了背景色(现在边框是白色的,但是页面的中间是应该的)。

我的控制台不断向我扔:

未捕获的TypeError:无法读取未定义的属性“替换”

HTMLButtonElement上的

。 (ajax-filter-posts.js?ver = 1:57) 在HTMLDivElement.dispatch(jquery.js?ver = 1.12.4:3)

在HTMLDivElement.r.handle(jquery.js?ver = 1.12.4:3)

在Object.trigger(jquery.js?ver = 1.12.4:3)

在Object.a.event.trigger(jquery-migrate.min.js?ver = 1.4.1:2)

HTMLButtonElement上的

。 (jquery.js?ver = 1.12.4:3)

在Function.each(jquery.js?ver = 1.12.4:2)

a.fn.init.each(jquery.js?ver = 1.12.4:2)

在a.fn.init.trigger(jquery.js?ver = 1.12.4:3)     在HTMLDivElement。 (ajax-filter-posts.js?ver = 1:76)

该怎么办?我的 ajax-filter-posts.js?ver = 1:57 看起来像这样:

(function($) {
$doc = $(document);
$doc.ready( function() {
    /*Retrieve posts*/
    var container = $('.container-async');
    container.each(function() {
        var $movie_tab_id = $(this).attr('id'),
            $movie_tab = "#" + $movie_tab_id,
            $content = $($movie_tab).find('.category-content.flw');
        function get_posts($params) {
            $.ajax({
                type: 'POST',
                url: blockter.ajax_url,
                data: {
                    action: 'do_filter_posts',
                    nonce: blockter.nonce,
                    params: $params
                },
                dataType: 'json',
                success: function(data, textStatus, XMLHttpRequest) {
                    if (data.status === 200) {
                        $content.html(data.content);
                    }
                    else if (data.status === 201) {
                        $content.html(data.message);
                    }
                },
                error: function(MLHttpRequest, textStatus, errorThrown) {

                },
                complete: function(data, textStatus) {

                    msg = textStatus;

                    if (textStatus === 'success') {
                        msg = data.responseJSON.found;
                    }

                    $content.removeClass('loading');
                }
            });
        }

        $($movie_tab).on('click', 'button[data-filter], .category-pagination li a', function(event) {
            if(event.preventDefault) { event.preventDefault(); }
            var $this = $(this),
                $mediaType = null;
            /*Set filter active*/
            if ($this.data('filter')) {
                $this.addClass('active').siblings().removeClass('active');
                $page = $this.data('page');
                $mediaType = $this.data('media');
                $postin = $this.data('postin');
            }
            else {
                /*Pagination*/
                $page = parseInt(($this.attr('href').replace(/\D/g,''));
                $mediaType = $this.parent().data('media');
                $postin = $this.parent().data('postin');
                $this = $('.category-filter button.active');
            }
            $content.addClass('loading');
            $content.append('<div class="ajaxloading"></div>');
            $params = {
                'page' : $page,
                'tax'  : $this.data('filter'),
                'term' : $this.data('term'),
                'qty'  : $this.closest($($movie_tab)).data('paged'),
                'media': $mediaType,
                'postin': $this.data('postin'),
            };

            /*Run query*/
            get_posts($params);
        });
        $('button[data-term="all-terms"]').trigger('click');
    });

    var $movie_tab_id = $('.container-async').attr('id'),
    $movie_tab = "#" + $movie_tab_id,
    $content = $($movie_tab).find('.category-content.flw'),
    $contents = $($movie_tab).find('.category-content.specific');

    $($movie_tab).on('click', 'button[data-filter], .category-pagination li a', function(event) {
        $.ajax({
            type: 'POST',
            url: blockter.ajax_url,
            data: {
                action: 'do_filter_posts',
                nonce: blockter.nonce,
                params: $params
            },
            dataType: 'json',
            success: function(data, textStatus, XMLHttpRequest) {
                if (data.status === 200) {
                    $content.html(data.content);
                    $contents.html(data.content);
                }
                else if (data.status === 201) {
                    $content.html(data.message);    
                    $contents.html(data.message);   
                }
            },
            error: function(MLHttpRequest, textStatus, errorThrown) {

            },
            complete: function(data, textStatus) {

                msg = textStatus;

                if (textStatus === 'success') {
                    msg = data.responseJSON.found;
                }

                $content.removeClass('loading');
                $contents.removeClass('loading');
            }
        });
        $contents.addClass('loading');
        $contents.append('<div class="ajaxloading"></div>');

    });
});
})(jQuery);

我的 $ movie_tab.php 看起来像这样:

<?php
$atts = vc_map_get_attributes( $this->getShortcode(), $atts );
extract( $atts );

$class_to_filter = '';
$class_to_filter .= vc_shortcode_custom_css_class( $inline_css, ' ' ) . $this->getExtraClass( $class ) . $this->getCSSAnimation( $css_animation );
$all_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, $class_to_filter, $this->settings['base'], $atts );

/*set columns*/
global $post;
$args = array(
    'post_type' => 'ht_movie',
);

$query = new WP_Query();
$query->query( $args );
if ( ! $query ) {
    return;
}
?>
<?php if( $query->have_posts() ): ?>
    <?php
    switch ($data) {
        case 'collections':
            $a = array(
                'tax'      => 'mv_collection', // Taxonomy
                'terms'    => $data_collections, // Get specific taxonomy terms only
                'active'   => false, // Set active term by ID
                'per_page' => $movie_per_tab // How many posts per page
            );
            break;
        case 'casts':
            $a = array(
                'tax'      => 'mv_actor', // Taxonomy
                'terms'    => $data_casts, // Get specific taxonomy terms only
                'active'   => false, // Set active term by ID
                'per_page' => $movie_per_tab // How many posts per page
            );
            break;
        default:
            $a = array(
                'tax'      => 'mv_genre', // Taxonomy
                'terms'    => $data_generes, // Get specific taxonomy terms only
                'active'   => false, // Set active term by ID
                'per_page' => $movie_per_tab // How many posts per page
            );
    }
    ?>

    <?php
        $tab_id = uniqid('tabid-');
        $drop_id = uniqid('dropid-');
    ?>
    
    <div class="flw container-async" id="<?php echo esc_attr( $tab_id ); ?>" data-paged="<?php echo esc_attr($a['per_page']); ?>">
        <?php  $terms  = get_terms($a['tax']); 
                $term_curr = $a['terms'];   
                $items = explode(',',$term_curr);
        ?>
        <?php if($term_curr == ''): ?>
            <div class="category-filter flw">
                <button data-filter="<?php echo esc_attr($terms[0]->taxonomy); ?>" data-term="all-terms" data-page="1" data-media="movie" class="active"><?php esc_html_e('All', 'blockter'); ?></button>
                <?php foreach ($terms as $term) : ?>
                <button data-filter="<?php echo esc_attr($term->taxonomy); ?>" data-term="<?php echo esc_attr($term->slug); ?>" data-page="1" data-media="movie"><?php echo esc_html($term->name); ?></button>            
                <?php endforeach; ?>
            </div>
            <!--for mobile version-->
            <div class="filter-cate-mobile" id="<?php echo esc_attr($drop_id);?>">
				<div class="flex-parent-cate">
					<div class="category-filter flw dropdown">
						<button class="dropbtn"  data-page="1"><?php echo esc_html__("SORT BY", 'blockter'); ?></button>
						<ul class="dropdown-content">
							<li><button data-filter="<?php echo esc_attr($terms[0]->taxonomy); ?>" data-term="all-terms" data-page="1" data-media="movie"><?php esc_html_e('All', 'blockter'); ?></button></li>
							<?php foreach ($terms as $term) : ?>
                                <li><button data-filter="<?php echo esc_attr($term->taxonomy); ?>" data-term="<?php echo esc_attr($term->slug); ?>" data-page="1" data-media="movie"><?php echo esc_html($term->name); ?></button></li>
							<?php endforeach; ?>
						</ul>
		            </div>
				</div>
			</div>
            <div class="category-content flw"></div>
        <?php else: ?>
            <div class="category-filter flw">
                <button data-filter="<?php echo esc_attr($terms[0]->taxonomy); ?>" data-term="all-terms" data-page="1" data-media="movie" class="active"><?php esc_html_e('All', 'blockter'); ?></button>
                <?php foreach ($items as $item) : ?>
                    <?php if($data == 'generes'): ?>
                        <button  data-filter="<?php echo esc_attr('mv_genre'); ?>" data-term="<?php echo esc_attr($item); ?>" data-media="movie"><?php echo esc_html($item); ?></button>
                    <?php elseif($data == 'collections'): ?>
                        <button  data-filter="<?php echo esc_attr('mv_collection'); ?>" data-term="<?php echo esc_attr($item); ?>" data-media="movie"><?php echo esc_html($item); ?></button>
                    <?php else: ?>
                        <button  data-filter="<?php echo esc_attr('mv_actor'); ?>" data-term="<?php echo esc_attr($item); ?>" data-media="movie"><?php echo esc_html($item); ?></button>
                    <?php endif; ?>
                <?php endforeach; ?>
            </div>
            <!--for mobile version-->
			<div class="filter-cate-mobile" id="<?php echo esc_attr($drop_id);?>" >
				<div class="flex-parent-cate">
					<div class="category-filter flw dropdown">
						<button class="dropbtn" data-page="1"><?php echo esc_html__("SORT BY", 'blockter'); ?></button>
						<ul class="dropdown-content">
							<li><button data-filter="<?php echo esc_attr($terms[0]->taxonomy); ?>" data-term="all-terms" data-page="1" data-media="movie"><?php esc_html_e('All', 'blockter'); ?></button></li>
							<?php foreach ($items as $item) : ?>
                                <?php if($data == 'generes'): ?>
                                <li><button data-filter="<?php echo esc_attr('mv_genre'); ?>" data-term="<?php echo esc_attr($item); ?>" data-media="movie"><?php echo esc_html($item); ?></button></li>
                                <?php elseif($data == 'collections'): ?>
                                <li><button data-filter="<?php echo esc_attr('mv_collection'); ?>" data-term="<?php echo esc_attr($item); ?>" data-media="movie"><?php echo esc_html($item); ?></button></li>
                            <?php else: ?>
                                <li><button data-filter="<?php echo esc_attr('mv_actor'); ?>" data-term="<?php echo esc_attr($item); ?>" data-media="movie"><?php echo esc_html($item); ?></button></li>
                                <?php endif; ?>
							<?php endforeach; ?>
						</ul>
		            </div>
				</div>
			</div> 
            <div class="category-content flw"></div>
        <?php endif; ?>
    </div>    
<?php 
    endif;
?>

0 个答案:

没有答案