首页 \ 问答 \ ember.js不会{{bindAttr}}

ember.js不会{{bindAttr}}

我试图使用{{bindAttr}}和输入字段的[viewName] .elementId将标签链接到输入字段。 它在单个条目视图中工作,但不是在显示多条记录时:它只是将标签链接到集合中的最后一个输入字段。 (这个过去在以前的迭代中使用了一个较旧的内部函数库,但现在它没有。)我创建了一个小提琴,但它的要点是:

{{#each controller}}
    <fieldset>              
        <label {{bindAttr for="view.tbFullName.elementId"}}>Full Name</label>
        {{view App.DetailTextField viewName="tbFullName" placeholder="Full Name" valueBinding="fullName" readonly="readonly"}}                              
    </fieldset>
{{/each}}

我想也许我可以创建一个collectionView并为viewName创建一个计算属性,它将为集合中的每个项目生成一个唯一的ID, 这里提到的另一个问题就是提到的。 但是,这样做太复杂了 - 只要用户点击相应的标签,我就可以让输入字段自己突出显示。

任何帮助赞赏。


I'm trying to link a label to an input field using the {{bindAttr}} and the input field's [viewName].elementId. It works on a single entry view, but not when there are several records being displayed: it just links the label to the last input field in the collection. (This used to work in a previous iteration using an older ember library but now it doesnt.) I've created a fiddle but the gist of it is:

{{#each controller}}
    <fieldset>              
        <label {{bindAttr for="view.tbFullName.elementId"}}>Full Name</label>
        {{view App.DetailTextField viewName="tbFullName" placeholder="Full Name" valueBinding="fullName" readonly="readonly"}}                              
    </fieldset>
{{/each}}

I thought maybe I could create a collectionView and create a calculated property for viewName which would generate a unique ID for each item in the collection, sort of mentioned in answer to another problem here. But that is getting WAY too complicated - just so that I can have the input field highlight itself if the user clicks on the corresponding label.

Any help appreciated.


原文:https://stackoverflow.com/questions/17556955
更新时间:2024-01-25 21:01

最满意答案

你可以做

    // Aircraft
    Response.Output.Write("<h3>Aircrafts</h3>");
    Response.Output.Write("<ul>");

    foreach (var aircraft in result.Trips.Data.Aircraft)
    {
        Response.Output.Write("<li>" + aircraft.Name + " " + aircraft.Code + "</li>");
    }

    Response.Output.Write("</ul>");

这会给类似的东西

<h3>Aircrafts</h3>
<ul>
  <li>Airbus 123456</li>
  <li>Airbus 123456</li>
  <li>Airbus 123456</li>
  <li>Airbus 123456</li>
</ul>

根据评论更新

或者像这样使用Label1.Text

    // Aircraft
    foreach (var aircraft in result.Trips.Data.Aircraft)
    {
        Label1.Text += aircraft.Name + aircraft.Code;
    }

You could do

    // Aircraft
    Response.Output.Write("<h3>Aircrafts</h3>");
    Response.Output.Write("<ul>");

    foreach (var aircraft in result.Trips.Data.Aircraft)
    {
        Response.Output.Write("<li>" + aircraft.Name + " " + aircraft.Code + "</li>");
    }

    Response.Output.Write("</ul>");

which would give something like

<h3>Aircrafts</h3>
<ul>
  <li>Airbus 123456</li>
  <li>Airbus 123456</li>
  <li>Airbus 123456</li>
  <li>Airbus 123456</li>
</ul>

Updated based on comment

Or like this using Label1.Text

    // Aircraft
    foreach (var aircraft in result.Trips.Data.Aircraft)
    {
        Label1.Text += aircraft.Name + aircraft.Code;
    }

相关问答

更多
  • 你可以尝试这样做: ... // get completed xml document $doc->preserveWhiteSpace = false; $doc->formatOutput = true; $xml_string = $doc->saveXML(); echo $xml_string; 您也可以在创建DOMDocument之后立即设置这些参数: $doc = new DomDocument('1.0'); $doc->preserveWhiteSpace = false; $doc-> ...
  • data = [['a', 'b', 'c'], ['aaaaaaaaaa', 'b', 'c'], ['a', 'bbbbbbbbbb', 'c']] col_width = max(len(word) for row in data for word in row) + 2 # padding for row in data: print "".join(word.ljust(col_width) for word in row) a b c ...
  • 你可以做 // Aircraft Response.Output.Write("

    Aircrafts

    "); Response.Output.Write("
      "); foreach (var aircraft in result.Trips.Data.Aircraft) { Response.Output.Write("
    • " + aircraft.Name + " " + aircraft.Code + "
    • "); ...
  • 使用文件列表在foreach循环中遍历并在foreach循环内执行grep。 set files = `ls *.stdout` foreach file ( $files ) grep -E "input files : 0” $file end Use the list of files to iterate through in the foreach loop and do the grep inside the foreach loop. set files = `ls *.stdout ...
  • 在这种情况下,您应该使用for循环。 问题是你有两个嵌套的foreach循环。 确保分数列表至少与文件列表一样大,否则您可能会获得超出范围异常的索引。 对于一个完全安全的解决方案,您应该添加一些检查,为清楚起见,我省略了这些检查。 List _fileNameList = new List(); List _counterFleschScore = new List(); for (var i=0;i<_fileNameList.Count; ...
  • 但是我很难将它打印出来 因为它是bytes对象。 只需decode结果: >>> print(rdd.toDebugString().decode("utf-8")) (4) PythonRDD[1] at RDD at PythonRDD.scala:48 [] | ParallelCollectionRDD[0] at parallelize at PythonRDD.scala:489 [] 有甚至有更好的方式来可视化图表吗? Spark UI中的DAG可视化通常绰绰有余。 but I'm ha ...
  • 试试这样: pathDiagram( model=ete.sem , file="PathDiagram" , max.rank=paste("item", 1:17, sep="") , ignore.double=FALSE , edge.labels="values" , size=c(8, 8) , node.font=c("He ...
  • 我可以想到的一种方式来美化输入(如果你正在编写更多的函数,可以获得更多的控制权)就是创建一个类并修改show方法..就像这样: # set your class name and its representation is list here. setClass( "stat_test", representation("list")) # show method (here's how the output would be printed # you can format to whatever y ...
  • 将模型包装在list ,并防止R尝试将其与I取消。 r3 <- d %>% group_by(w) %>% do(data.frame(s1 = I(list(lm(y ~ x, .))), s2 = sum(.$y), s3 = { z <- seq_along(.$x) sum(z) })) #Sourc ...
  • Wordpress有一个名为wpautop的函数,它将双换行符转换为段落元素。 我不建议使用库来纠正用户错误格式化的HTML。 你将被迫猜测正确的解释。 (就像过去那些旧浏览器一样,这并不是一件成功的事)。 例如,代码中的结束标记应该放在哪里? 没人知道! 我宁愿寻找(或创建)一种方法来检查无效的HTML,然后通知用户,让他们纠正它。 用于检查有效性的PHP函数(回答SO问题) 使用W3C验证器API Wordpress has a function called wpautop whic ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)