2010-05-18 61 views
0

我試圖根據用戶操作在此插件中更改extraParams是否可以訪問JQuery插件的內部屬性?

var t = new $.TextboxList('#entSearch', {unique: true, plugins: { 
      autocomplete: { 
       minLength: 3, 
       queryRemote: true, 
       placeholder: false, 
       remote: { 
        url: "{{=URL(r=request, f='call/json/suggest')}}", 
        extraParams: {type: "", guid: ""} 
        } 
       } 
      } 
     }); 

執行以下行引發錯誤:autocomplete.remote未定義

var tmp = autocomplete['remote']['extraParams']['type']; 

是否有訪問插件的這些內部屬性,像我將引用他們的字典的方法嗎?

+1

你可以將它們定義爲變量上面? – alex 2010-05-18 02:47:10

回答

1

將它定義爲一個變量,以便您稍後可以訪問它。

var plugins = { 
    autocomplete: { 
     minLength: 3, 
     queryRemote: true, 
     placeholder: false, 
     remote: { 
      url: "{{=URL(r=request, f='call/json/suggest')}}", 
      extraParams: {type: "", guid: ""} 
     } 
    }, 
    t = new $.TextboxList('#entSearch', {unique: true, plugins: plugins}); 

然後你就可以訪問它,例如:

var tmp = plugins.autocomplete.remote.extraParams.type; 
// ... or ... 
var tmp = plugins['autocomplete']['remote']['extraParams']['type']; 
+0

謝謝 - 我現在可以訪問這些值並在'插件'中更新它們,但我無法將它們設置爲't'。出於某種原因,我無法以同樣的方式訪問't':'t.plugins.autcomplete.remote.extraParams.type'。這正是我試圖用上面的「自動完成」所做的。任何想法爲什麼這不起作用? – 2010-05-18 04:00:06

+0

這取決於如何設置TextboxList插件。如果不知道這一點,你無法幫助你。但他們的方式,你試圖訪問信息絕對不會工作。 – 2010-05-18 06:05:56

相關問題