0

我想在 jQuery 革命滑块中加载 JSON 提要。从提要加载有效,但旋转滑块不将其用作项目。

我怎样才能让它工作?

我现在有这个代码:

            var setREVStartSize = function() {
                        var tpopt = new Object(); 
                            tpopt.startwidth = 100;
                            tpopt.startheight = 850;
                            tpopt.container = jQuery('#tv');
                            tpopt.fullScreen = "on";
                            tpopt.forceFullWidth="on";

                        tpopt.container.closest(".rev_slider_wrapper").css({height:tpopt.container.height()});tpopt.width=parseInt(tpopt.container.width(),0);tpopt.height=parseInt(tpopt.container.height(),0);tpopt.bw=tpopt.width/tpopt.startwidth;tpopt.bh=tpopt.height/tpopt.startheight;if(tpopt.bh>tpopt.bw)tpopt.bh=tpopt.bw;if(tpopt.bh<tpopt.bw)tpopt.bw=tpopt.bh;if(tpopt.bw<tpopt.bh)tpopt.bh=tpopt.bw;if(tpopt.bh>1){tpopt.bw=1;tpopt.bh=1}if(tpopt.bw>1){tpopt.bw=1;tpopt.bh=1}tpopt.height=Math.round(tpopt.startheight*(tpopt.width/tpopt.startwidth));if(tpopt.height>tpopt.startheight&&tpopt.autoHeight!="on")tpopt.height=tpopt.startheight;if(tpopt.fullScreen=="on"){tpopt.height=tpopt.bw*tpopt.startheight;var cow=tpopt.container.parent().width();var coh=jQuery(window).height();if(tpopt.fullScreenOffsetContainer!=undefined){try{var offcontainers=tpopt.fullScreenOffsetContainer.split(",");jQuery.each(offcontainers,function(e,t){coh=coh-jQuery(t).outerHeight(true);if(coh<tpopt.minFullScreenHeight)coh=tpopt.minFullScreenHeight})}catch(e){}}tpopt.container.parent().height(coh);tpopt.container.height(coh);tpopt.container.closest(".rev_slider_wrapper").height(coh);tpopt.container.closest(".forcefullwidth_wrapper_tp_banner").find(".tp-fullwidth-forcer").height(coh);tpopt.container.css({height:"850px"});tpopt.height=coh;}else{tpopt.container.height(tpopt.height);tpopt.container.closest(".rev_slider_wrapper").height(tpopt.height);tpopt.container.closest(".forcefullwidth_wrapper_tp_banner").find(".tp-fullwidth-forcer").height(tpopt.height);}
             }  

                // CALL PLACEHOLDER
                setREVStartSize();


            //var tpj=jQuery;               
            //tpj.noConflict();             
            var revapi1;




            $( document ).ready(function() {

            if($('#tv').revolution == undefined)
                revslider_showDoubleJqueryError('#tv');
            else
               revapi1 = $('#tv').show().revolution(
                {

                    dottedOverlay:"none",
                    delay:1800,
                    startwidth:100,
                    startheight:850,
                    hideThumbs:200,

                    thumbWidth:100,
                    thumbHeight:50,
                    thumbAmount:1,

                    navigationType:"none",
                    navigationArrows:"solo",
                    navigationStyle:"round",

                    touchenabled:"off",
                    onHoverStop:"off",

                    swipe_velocity: 0.7,
                    swipe_min_touches: 1,
                    swipe_max_touches: 1,
                    drag_block_vertical: false,


                    keyboardNavigation:"off",

                    navigationHAlign:"center",
                    navigationVAlign:"bottom",
                    navigationHOffset:0,
                    navigationVOffset:20,

                    soloArrowLeftHalign:"left",
                    soloArrowLeftValign:"center",
                    soloArrowLeftHOffset:20,
                    soloArrowLeftVOffset:0,

                    soloArrowRightHalign:"right",
                    soloArrowRightValign:"center",
                    soloArrowRightHOffset:20,
                    soloArrowRightVOffset:0,

                    shadow:0,
                    fullWidth:"on",
                    fullScreen:"on",

                    spinner:"spinner0",

                    stopLoop:"off",
                    stopAfterLoops:-1,
                    stopAtSlide:-1,

                    shuffle:"off",


                    forceFullWidth:"on",                        
                    fullScreenAlignForce:"off",                     
                    minFullScreenHeight:"",                     
                    hideTimerBar:"on",                      
                    hideThumbsOnMobile:"off",
                    hideNavDelayOnMobile:1500,
                    hideBulletsOnMobile:"off",
                    hideArrowsOnMobile:"off",
                    hideThumbsUnderResolution:0,

                    hideSliderAtLimit:0,
                    hideCaptionAtLimit:0,
                    hideAllCaptionAtLilmit:0,
                    startWithSlide:0,
                    fullScreenOffsetContainer: ""   
                });




            }); //ready

加载 JSON 提要

function load_json(){
    $.ajax({
        type: "GET",
        url: "#",
        dataType: 'json',

        async: true, /* If set to non-async, browser shows page as "Loading.."*/
        cache: false,
        timeout:50000, /* Timeout in ms */

        success: function(data){ /* called when request to barge.php completes */
            $.each(data.items, function(i,post){

                       $('#slides').append('' + post.html + '');

                    });

                  // $('#slides').html(data.title);

            setTimeout(
                load_json, /* Request next message */
                10000 /* ..after 1 seconds */
            );
        },
        error: function(XMLHttpRequest, textStatus, errorThrown){
            addmsg("error", textStatus + " (" + errorThrown + ")");
            setTimeout(
                load_json, /* Try again after.. */
                10000); /* milliseconds (15seconds) */
        }

    });
};

load_json();

html:

 <div id="rev_slider_1_1_wrapper" class="rev_slider_wrapper fullscreen-container" style="background-color:#fff;padding:0px;">
<div id="tv" class="rev_slider fullscreenbanner" style="display:none;">

    <ul><div id="slides"></div></ul>

<div class="tp-bannertimer"></div>  </div>
</div>

json输出

{
  "items": [{
    "html": " <li data-transition=\"fade\" data-slotamount=\"2\" data-masterspeed=\"300\" data-saveperformance=\"on\">..<\/li>"
}, {
    "html": " <li data-transition=\"fade\" data-slotamount=\"2\" data-masterspeed=\"300\" data-saveperformance=\"on\">..<\/li>"
}]
  }
4

0 回答 0