(1)如何引用jquery数据和(2)如何连接字符串? [英] (1) how to reference jquery data and (2) how to concatenate strings?
问题描述
是jQuery和javaScript的新手。
我如何(1)提取数据项并(2)将其连接到下面的字符串。
下面的工作示例可以说明alexLink如何包含我想要的数据。
Am new to jQuery and javaScript.
How can I (1) extract a data item and (2) concatenate it to a string below.
This working sample below works and demonstrates how "alexLink" contains the data I want.
window.open(data.node.data.alexLink, "_blank");
我想获取alexLink内容并将它们连接成以下javaScript(调用python)语句。你不必知道这个链接是如何工作的,因为我只想要连接内容的语法,这是一个URL。
I want to take alexLink contents and concatenate them into the following javaScript (call to python) statement. You don't have to know how this link works as I just want the syntax for concatenating the content, which is a URL.
ajax("{{=URL('default', INSUERT_CONTENTS_HERE)}}", [], ':eval');
当我尝试查看内容警报时(data.node.data.alexLink)我什么也看不见。
为了澄清这个问题,我不知道不希望 var = string1.concat(string2)
反而希望该行读取:text.concat( string1)+ .concat(additional_text)
是javaScript中可能的(不使用var =)?
谢谢,
Alex Glaros
when I try to view the contents alert(data.node.data.alexLink) I see nothing.
To clarify the problem, I don't want var = string1.concat(string2)
Instead want the line to read: "text".concat(string1) + .concat(additional_text)
is that possible in javaScript (not using the "var =")?
thanks,
Alex Glaros
<script type="text/javascript">
// Initialize Fancytree
$("#alexTree").fancytree({
checkbox: true,
selectMode: 3,
source: {url: tree_url},
dataType: "json",
postProcess: function(event, data){
data.result = convertData(data.response);
},
select: function(event, data) {
ajax("{{=URL('default', 'navigate_to_txonomy_column', vars=dict(specificTaxonomyColumnID=specificTaxonomyColumnID))}}", [], ':eval');
}
});
});
</script>
{{## ajax line above used to be: window.open(data.node.data.alexLink, "_blank");}}
我尝试过:
我尝试过使用提示框来显示数据但它出现了空白。
What I have tried:
I've tried using the alert box to show the data but it came up blank.
推荐答案
( # alexTree)。fancytree({
复选框: true ,
selectMode: 3 ,
来源:{url:tree_url},
dataType: json ,
postProcess: function (事件,数据){
data.result = convertData(data.response);
},
选择: function (事件,数据){
ajax( < span class =code-string> {{= URL('default','navigate_to_txonomy_column',vars = dict(specificTaxonomyColumnID = specificTaxonomyColumnID))}},[],' :eval');
}
});
});
< / script>
{{## ajax以上行曾经是: window .open(data.node.data。 alexLink , _ blank);}}
("#alexTree").fancytree({ checkbox: true, selectMode: 3, source: {url: tree_url}, dataType: "json", postProcess: function(event, data){ data.result = convertData(data.response); }, select: function(event, data) { ajax("{{=URL('default', 'navigate_to_txonomy_column', vars=dict(specificTaxonomyColumnID=specificTaxonomyColumnID))}}", [], ':eval'); } }); }); </script> {{## ajax line above used to be: window.open(data.node.data.alexLink, "_blank");}}
我尝试过:
我尝试过使用提示框来显示数据但它出现了空白。
What I have tried:
I've tried using the alert box to show the data but it came up blank.
如评论中所述,如果data.node.data.alexLink不包含值,则需要进行一些调试。
Concat非常简单。 ajax({{= URL('default','+ data.node.data.alexLink +')}},[],':eval');
As mentioned in the comments you'll need to do some debugging if data.node.data.alexLink does not contain a value.
Concat is very simple. ajax("{{=URL('default', '" + data.node.data.alexLink + "')}}", [], ':eval');
这篇关于(1)如何引用jquery数据和(2)如何连接字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!