0

我想知道如何将 jQuery / Mobile Swipe 事件添加到我的 Wordpress 幻灯片放映中:

我希望能够在 Mobile 上使用它来“滑动”我的幻灯片。

幻灯片放映代码 // 使用 WP 的 PHP 进行标记:

<!-- Top of Page Slider FRAGILE -->

<div id="photo-rotatorWrapper">

<div id="photosubwrap" style="min-height: 280px; max-height: 280px;">

<div id="photo-rotator" style="">
<?php $slide_id=1; ?>
<?php
 $featuredPosts = new WP_Query();
 $featuredPosts->query("showposts=3");
 while ($featuredPosts->have_posts()) : $featuredPosts->the_post();
 ?>

    <div id="slide-<?php echo $slide_id; $slide_id++;?>">
     <a href="<?php the_permalink() ?>" class="post-image">
         <?php the_post_thumbnail( 'rotator-post-image' ); ?>
         <span class="title" style="font-style:italic; color:#999;"><?php the_title(); ?></span>
     </a>
     </div>

    <?php endwhile; ?><!--/close loop-->

    <ul id="slide-nav">
        <?php $nav_id=1; ?>
        <?php while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); ?>
            <li>
                <a href="#slide-<?php echo $nav_id; ?>">
                    <span class="thumbnail" style="display:none;">
                    </span>
                    <p style="color:#F93; font-family:Georgia, 'Times New Roman', Times, serif; font-size: 18px;"><? the_title(); $nav_id++;?></p>

                    <div style="">

                    <!--<?php the_excerpt(); ?>-->

                    <?php if($text= get_post_meta($post->ID, "slidetext", true)) { ?>
                         <div class="">

                         <p style="font-weight: normal; color: #333; font-family: Arial, Helvetica, sans-serif; font-size: 14px;"><?php echo $text; ?></p> 

                         </div>
                        <?php } //else { print"<div>"; } ?>  

                    </div>   
                </a>
            </li>
        <?php endwhile; ?><!--/close loop-->
        </ul>
        </div>

</div>
</div>

<!-- End Top page Slider FRAGILE -->

允许幻灯片放映的脚本:

<script type="text/javascript">

jQuery(document).ready(function($){
    $("#photo-rotator").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 6000);
});

</script>

更新我刚刚尝试过

<script>
$("#slide-1").swiperight(function() {
    $.mobile.changePage("#slide-2");
});
</script>

没有这样的运气~

有什么建议么 - ?

4

1 回答 1

1

为了扩展我的评论,这里是如何使用 jQuery UI 的选项卡小部件以编程方式更改选项卡:

//cache all the tabs (I called them slides...)
//get the number of tabs
var $slides    = $('div[id^="slide"]')
    slideCount = $slides.length;

//bind the event handlers necessary
$slides.bind('swipeleft', function () {
    //this is to go to the next index

    //get current slide index and figure out the next one
    var currentIndex = $(this).index();
    if ((currentIndex + 1) < slideCount) {
        currentIndex++;
    } else {
        //the end was reached, so go back to the first tab
        currentIndex = 0;
    }

    //now select the new tab
    $("#photo-rotator").tabs( "select" , currentIndex);
}).bind('swiperight', function () {
    //this is to go to the previous index

    //get current slide index and figure out the previous one
    var currentIndex = $(this).index();
    if ((currentIndex - 1) >= 0) {
        currentIndex--;
    } else {
        //the beginning was reached, so go to the last tab
        currentIndex = slideCount;
    }

    //now select the new tab
    $("#photo-rotator").tabs( "select" , currentIndex);
});
于 2012-05-16T21:30:13.417 回答