0

我在 wordpress 中使用了很棒的 CodaSlider 来向我的页面添加一个选项卡式功能,但遇到了一些问题。

CodaSlider 使用一个查看当前内容并自动定义高度的脚本,但是,我可以选择打开/关闭滑块内的 div 以显示更多内容,但是由于滑块已经定义了一个高度,它不会自动更新。

我的想法是添加一段 JQuery 来刷新滑块的 div 从而显示新内容,而不必一直重新加载整个页面。

到目前为止,这就是我所拥有的:

<div class="video-centre">
  <div class="video-title"> <img src="<?php echo get_bloginfo('template_url') ?>/images/video-propertiesforsale.jpg" alt="properties for sale" /> </div>
    <div class="video-point"> <img src="<?php echo get_bloginfo('template_url') ?>/images/video-point.jpg" alt="video pointer" /> </div>
    <div class="video-thumb">
      <div class="coda-slider" id="slider-id">
        <div>
          <h2 class="title"><span>Crouch End</span></h2>
          <?php the_field('crouch_end'); ?>
            <p class="video-more2"><a href="javascript:animatedcollapse.show(['expandable-2'])" id="refresh">View More</a></p>
            <div id="expandable-2">
            <?php the_field('properties_for_sale_hidden'); ?>
            <p class="video-close2"><a href="javascript:animatedcollapse.hide(['expandable-2'])" id="refresh">Close</a></p>
         </div>
        </div>





<script>
var $r = jQuery.noConflict();
    $r(function() {
      $r("#refresh").click(function(evt) {
         $r(".panel").load("index.php")
         evt.preventDefault();
      })
    })
</script>

我遇到的问题是脚本加载了整个页面,而不是它应该加载的实际内容,我似乎无法让它做我想做的事。

我希望以上内容可以理解,在我的脑海中听起来不错:S

4

1 回答 1

0

是的,.load旨在加载页面的全部内容。你可以运行.load,然后通过孩子们得到你想要的:

var div = $('<div/>').load('index.php');
$('.panel').replaceWith(div.find('.panel'));
于 2012-09-18T16:09:59.867 回答