0

我正在使用 jQuery 我想发送一个自定义查询字符串参数以及 node_id,例如 json 中的 _type,如下所示

[{
    "id":"2",    
    "label":"Title for folder",    
    "branch":[],    
    "inode":true,    
    "open":false,    
    "icon":"folder",    
    "_type":"library"
}]

我正在尝试ajaxhook如下所示

ajaxHook: function (item, settings) {
    // the default implementation changes the URL by adding the item ID at the end    
    alert(this.itemData._type);    
    settings.url += (item ? this.getId(item) : '');    
}

我无法_type使用此方法获取我的自定义属性。

4

2 回答 2

0

this.itemData 是一个数组,因此或者你循环它,或者做一些类似的事情:

alert(this.itemData[0]._type);
于 2015-10-20T14:40:40.763 回答
0

以下是执行此操作的正确方法:

  ajaxHook: function (item, settings) {
                    // the default implementation changes the URL by adding the item ID at the end
                    if (item != null) {
                        var ItemData = this.itemData(item);
                        settings.url += (item ? this.getId(item) : '') + '&type=' + ItemData._type;
                    }
                },
于 2015-10-21T07:21:13.060 回答