2011-04-12 42 views
0

我正在使用一個jQuery圖像滑塊,我想通了,如何將圖像從數據庫傳遞到我的圖像滑塊,但即時通訊的描述文本傳遞給每個圖像的問題,因爲圖像形成是在腳本中,我不知道如何將eval(「描述」)傳遞給腳本。下面是代碼:將描述文本從數據庫傳遞給jquery圖像滑塊

<script type="text/javascript"> 
       if (!window.slider) var slider = {}; 
       slider.data = [{ "id": "slide-img-1", "client": "nature beauty", "desc": "With up to 30 used caravans for you to choose from, you will soon be able to hit the open road...<br /> Come along and browse at your leisure or take a look at a selection of our current stock." }, { "id": "slide-img-2", "client": "nature beauty", "desc": "" }, { "id": "slide-img-3", "client": "nature beauty", "desc": "add your description here" }, { "id": "slide-img-4", "client": "nature beauty", "desc": "add your description here" }, { "id": "slide-img-5", "client": "nature beauty", "desc": "add your description here" }, { "id": "slide-img-6", "client": "nature beauty", "desc": "add your description here"}]; 

,所以我想通過類似 「說明」: '<%的eval( 「說明」)%>'

<div id="slide-runner"> 

<asp:Repeater ID="rptJquery" runat="server"> 

<ItemTemplate> 
<a href=""> 
<img ID='<%#Eval("slideshowID") %>' src='<%#String.Format("/images/slideshow/{0}", Eval("imgURL"))%>' class="slide"/> 
</a> 
</ItemTemplate> 
</asp:Repeater> 
</div> 
+0

是<%#Eval(「說明」)%>不適用於您?我的意思是你試過了嗎? – 2011-04-12 21:10:29

+0

沒有它的不工作,我想你不能使用它在javascripting – 2011-04-13 09:10:21

回答

0

的最佳方式實現這種情況,就是將數據提供爲JSON,並且在加載圖像滑塊時,在初始化時提供此數據。

如果您正確提供,插件應該正確處理這種類型的數據。

如果您可以告訴我們您的插件的名稱,也許我們可以爲您提供一些樣品。

+0

thnx爲你的reple,下面是我用於我的項目的圖像庫鏈接:http://www.dreamcss.com/2009/04/ create-beautiful-jquery-sliders.html,可以爲我提供任何有關上述場景的陰影 – 2011-04-13 09:48:40