简体   繁体   English

在DashCode中,如何从onClick处理程序访问dataArray

[英]In DashCode, how to access the dataArray from an onClick handler

I have a list that is automatically populated from an XML DataSource using bindings. 我有一个使用绑定从XML数据源自动填充的列表。

Each XML record contains a title, a description and a URL 每个XML记录均包含标题,描述和URL

Each UI row contains a title and a description. 每个UI行均包含标题和描述。

When onclick is called on the title, I would like to call the openURL with the URL specified in the DataSource. 在标题上调用onclick时,我想使用在数据源中指定的URL调用openURL。

Is it possible to identify the current selection and navigate in the datamodel from the onclickHandler? 是否可以标识当前选择并通过onclickHandler在数据模型中导航?

In a Dashcode project I'm working on right now I have a datasource that includes a URL to the product on Amazon.com. 我现在正在Dashcode项目中工作,我有一个数据源,其中包含指向Amazon.com上产品的URL。 I haven't done this from the list view, but from my detail view I created a link to the Amazon page for the currently displayed product. 我还没有从列表视图中完成此操作,但是从详细信息视图中,我创建了指向当前显示产品的Amazon页面的链接。

On the detail layout the URL field is transformed to be: 在详细信息布局上,URL字段被转换为:

"Click here to purchase the product on Amazon.com." “单击此处可在Amazon.com上购买产品。”

And the word here is a standard html link. 这里的单词是标准的html链接。

I used a Value Transformer to do this. 我使用值转换器来做到这一点。 In my data source the URL field contains a fully qualified URL to the product on Amazon.com. 在我的数据源中,URL字段包含Amazon.com上产品的完全限定URL。 So where you see "value" in the code below Dashcode is replacing that with a URL in the HTML code that is then included in the page. 因此,在Dashcode下面的代码中看到“值”的地方是用HTML代码中的URL替换它,然后该URL包含在页面中。

myBuildAmazon = Class.create(DC.ValueTransformer,{
    transformedValue: function(value){
        // Insert Code Here
        value="Click <a href="+value+" target='_blank' >here</a>  to purchase the product on Amazon.com.";
        return value;
    }
});

One important thing is that when you bind the datasource to the field select HTML from the popup menu that comes up rather than Text. 重要的一件事是,当您将数据源绑定到字段时,请从出现的弹出菜单中选择HTML,而不是Text。

I hope this helps. 我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM