2014-10-31 90 views
0

我有以下代碼。JQuery替換var值

var fancyProductDesigner = jQuery('#fancy-product-designer-310938') 
         .fancyProductDesigner({ 
          uploadDesigns: 0, 
          customTexts: 1, 
          imageDownloadable: 1, 
          saveAsPdf: 0, 
          printable: 1, 
          dimensions: { 
           sidebarNavSize: 30, 
           sidebarContentWidth: 168, 
           sidebarSize: 887, 
           productStageWidth: 490, 
           productStageHeight: 490 
          } 
         }).data('fancy-product-designer'); 

我想改變寬度和高度。位置(尺寸:)與用戶輸入的尺寸。

我需要知道如何設置/更改這些值。

我已經試着看看對象是否存在。

alert(typeof $('fancy-product-designer').data('dimensions')); 

但它說未定義....

我的頁面是http://www.panel-it.eu/shop/ontwerp-sticker-effe-kleuren/#

並按下黃色欄時出現的元素。


我登錄

console.log(jQuery('#fancy-product-designer-310938').data('fancy-product-designer')); 

但無法找到一個方法來重置尺寸。

我注意到:setStageDimensions

能有人幫助我一起去嗎?

+1

呃,我剛剛檢查了你的panel-it.eu網站,而JQuery實際上並沒有定義......你是否記得包含該文件? – 2014-10-31 13:00:01

+3

@DylanCorriveau jQuery是在那裏定義的。使用'jQuery'而不是'$'。 – 2014-10-31 13:04:43

+1

我不知道fancyProductDesigner並沒有很快找到文檔,但是您確定,數據函數設置了您之前定義的屬性嗎? – 2014-10-31 13:16:09

回答

0

此方法返回可用於看中產品設計師的所有方法的對象:

var data = jQuery('#fancy-product-designer-310938').data('fancy-product-designer'); 

裏面你找到一個方法setStageDimensions(),您可以使用像這樣:

// first argument is the width, second the height 
data.setStageDimensions(200, 400); 

現在內部尺寸productStageWidth是200和productStageHeight是400.一種方法來改變我找不到的其他維度。作爲@ boulder_02在他的評論中提到的數據方法不會存儲您的原始對象,但它自己返回.fancyProductDesigner()