2017-01-25 9 views
0

Я использую ползунок HillBilly для одного из моих сайтов. Он отлично работает, но я также хотел использовать поле заголовка в слайдере. Я скорректировал код, но там, где название должно быть, я просто получаю «Неопределенный». Насколько я могу судить, код верен. Может ли кто-нибудь просмотреть мой код, чтобы увидеть, где я испортился?SharePoint 2010 Настройка запроса CAML

Благодаря

<style type="text/css"> 
.hillbillyBanner { position: relative; overflow: auto; } 
.hillbillyBanner li { list-style: none; } 
.hillbillyBanner ul li { float: left; height: 200px; width: auto;} 
.hillbillyBanner ul {margin-left: -40px;} 
p {margin-left: 25px;} 
h2 {margin-left: 15px;} 
</style> 
<script type="text/javascript"> 
    jQuery(document).ready(function($) { 
     var sliderList = "Announcements";// Name of the list that contains slides 
     var slideTitleField = "Title"; 
     var slideContentField = "Body"; //Name of the Rich text field that has slide content 
     var slideBackgroundImageField = "Image"; //Name of the picture field to use as background image 
     HillbillySlider(sliderList,slideTitleField,slideContentField,slideBackgroundImageField); 
    }); 
function HillbillySlider(sliderList,slideTitleField,slideContentField,slideBackgroundImageField) { 
    //query to retrieve all items 
    var query = "<Query><Where><And><Neq><FieldRef Name='ID' /><Value Type='Number'></Value></Neq><Eq><FieldRef Name='Active' /><Value Type='Boolean'>1</Value></Eq></And></Where></Query>"; 
    //return fields for slide content and background picture 
    var camlViewFields = "<ViewFields><FieldRef Name='"+slideTitleField+"' /><FieldRef Name='"+slideContentField+"' /><FieldRef Name='"+slideBackgroundImageField+"' /></ViewFields>"; 
    $().SPServices({ 
      operation: "GetListItems", 
      async: true, 
      listName: sliderList, 
      CAMLViewFields: camlViewFields, 
      CAMLQuery: query, 
      completefunc: function(xData, Status) { 
       $(xData.responseXML).SPFilterNode("z:row").each(function() { 
       var slideTitleField = ($(this).attr("ows_"+slideTitleField)); 
       var slideContent = ($(this).attr("ows_"+slideContentField)); 
       var picture = $(this).attr("ows_"+slideBackgroundImageField)==undefined?"":$(this).attr("ows_"+slideBackgroundImageField).split(",")[0]; 
       //create slide (li) and append it to other slides 
       $("#hillbillySlider").append("<li style=\"background-image: url('"+picture +"');\"><h2>"+slideTitleField+"</h2><p>"+slideContent+"</p></li>"); 
      }); // end completefunc 
      //start the slider 
      $('.hillbillyBanner').unslider(); 
     } 
    }); // end SPServices call`enter code here` 
} 
</script> 

ответ

0

Ах нашел ответ, который я случайно установить вар титул дважды, и он перечеркнул вне.

Так что

var slideTitleField = ($(this).attr("ows_"+slideTitleField)); 
      var slideContent = ($(this).attr("ows_"+slideContentField)); 
      var picture = $(this).attr("ows_"+slideBackgroundImageField)==undefined?"":$(this).attr("ows_"+slideBackgroundImageField).split(",")[0]; 
      //create slide (li) and append it to other slides 
      $("#hillbillySlider").append("<li style=\"background-image: url('"+picture +"');\"><h2>"+slideTitleField+"</h2><p>"+slideContent+"</p></li>"); 

был изменен следующим образом:

var slideTitle = ($(this).attr("ows_"+slideTitleField)); 
       var slideContent = ($(this).attr("ows_"+slideContentField)); 
       var picture = $(this).attr("ows_"+slideBackgroundImageField)==undefined?"":$(this).attr("ows_"+slideBackgroundImageField).split(",")[0]; 
       //create slide (li) and append it to other slides 
       $("#hillbillySlider").append("<li style=\"background-image: url('"+picture +"'); background-repeat: no-repeat;\"><h2>"+slideTitleField+"</h2><p>"+slideContent+"</p></li>"); 

 Смежные вопросы

  • Нет связанных вопросов^_^