Polymer.dart: How to set read-only property to read-write attribute? - data-binding

I have a polymer component(lets call it component-one) which exposes an attribute value. I want to use this in another polymer component which has an Observable list property called data. I want to do the following:
<template repeat="{{obj in data}}">
<component-one value="{{obj}}"></component-one>
</template>
But it generates error saying that there is no "obj=" method.
Can somebody let me know how to data-bind a read-only property to a read-write attribute?
Thanks for your time!

Seems you are running into this bug https://code.google.com/p/dart/issues/detail?id=17981. This bug seems to be fixes for about 6 weeks.
You should check that you use a recent Dart version and a recent Polymer package.
If this doesn't help please add a comment.

Related

Why use getAttribute and setAttribute?

I'm trying to better understand the fundamentals of A-Frame.
I understand how to use the getAttribute() and setAttribute() methods for
accessing component data. However I don't understand why we use them instead of just accessing the components attributes using dot notation.
A lot of people use something like:
document.querySelector("#myText").getAttribute('text').value
Why not use:
document.querySelector("#myText").components['text'].data.value
Is there something wrong with using that second way? What are the pitfalls? In my experiments I have experienced both ways returning "undefined" due to the code running before the scene is finished loading, but I have learned how to avoid that using the "loaded" event.
As you can see at this glitch example (https://glitch.com/~text-hierarchy) I've successfully printed data to the console using both ways.
Part of the standard
Both getAttribute(prop) and setAttribute(prop, value) are used to get/set attributes of any other DOM elements. MDN links here (get, set)
Compatible with aframe components
If you have a update() function in your a-frame component, setAttribute() calls it, notyfing, that a property of a component has changed.
It's not mandatory, it's even faster to modify some properties directly, but it has risks, like undefined behavior if a developer uses update() to monitor changes.

Emberjs CollectionView changes from 0.9.7.1 to 1.0.pre?

I had some code that connected an ArrayController with CollectionView that no longer works once I upgrade to 1.0.pre.
It seems that CollectionView no longer passes each element of the collection to its template view class?
I've distilled my issue to this jsFiddle: http://jsfiddle.net/chaodoze/CbwCN/
Notice it outputs to "1,2,3" on each line in 1.0.pre
In 0.9.7.1, it outputs correctly as a single digit on each line.
Am I doing something wrong here or is this a bug?
What is the best way to work-around this issue?
Thanks!
In 1.0.pre the view's context has changed. When you access {{content}} you are really accessing {{controller.content}}, which is [1,2,3]. You need to access the view's content, which in the individual number, that is done with {{view.content}}.
See http://jsfiddle.net/CbwCN/2/

How can I react to DOM events that Meteor Templates don't support?

Currently meteor supports a limited number of events that we can react to from our template definitions. I would like a way to react to events beyond this predefined list. I want the freedom to add any event, even custom events, to the list of possible events in a template.
One idea I had would be to set up a jquery event handler somewhere that listens for the unsupported event and have it set a session variable:
$(form).submit( ->
Session.set('formSubmitted', true)
And then use that session variable when rendering a template:
Template.confirmation.submitted = ->
return Session.get('formSubmitted')
<template name="confirmation">
{{#if submitted}}
<!-- do whatever -->
{{/if}}
</template>
But this is just a workaround and doesn't really address the issue. Is there a real Meteor-way of doing this? Is this something I can do with the new Spark implementations?
NOTE: Please ignore the fact that I'm using the submit event here. I know I can just bind a click event to the submit button, but that's beside the point.
NOTE 2: The accepted answer to this question is also just a workaround.
The rendered callback is what I use to do this.
http://docs.meteor.com/#template_rendered
The callback gives you template instance you should use to find the dom elements you need: http://docs.meteor.com/#template_inst
Untested example below ;)
Template.foo.rendered = ->
$(this.find("form")).submit ->
Session.set 'formSubmitted', true
Using a Session variable than to switch the view is a matter of taste I think.
I have an app State stored in the Session, that toggles Templates. Additionally the backbone package is very useful to provide some meaningful urls.

How to bind property of View to property of class using Flex MATE

Lately i discovered MATE (for Flex development) and was wondering: how do i bind a property in a view (actually a navigatorcontent component) to another property in a class so that they stay in synchronization (meaning that whenever the property in the class changes the property in the view also changes).
So if we have a view called Target.mxml and a property targertProp how do we bind it to the class called SourceClass with property SourceProp?
Thanks in advance
For future use:
fiction has answered the question correctly.
Actually it should have been formulated this way!
<Injectors target="{Target}">
<PropertyInjector targetKey="targertProp"
source="{SourceClass}"
sourceKey="SourceProp"/>
</Injectors>
Of course SourceProp must be [Bindable]
Read my article below
http://vinothbabu.com/2010/03/21/introduction-to-mate-framework/
on how you use the Injectors Tag to play with. Its a very simple example. Let me if you were looking for something else.

QWebElement information where on page it is rendered?

Looks like access to DOM and rendering details of HTML tags are not availabel in qt 4.5.x .
Current snapshot QWebElement looks like proper class to be used there
Anybody can give me info if is it possible to get from QWebElement information where on page it was rendered ?
Or there are other ways to get that information ?
TIA, regards
In Qt 4.5, you need to write that as a JavaScript expression and evaluate that with QWebFrame::evaluateJaveScript().
Just for reference's sake: for 4.6 and up, QWebElement.geometry() is the best way to do this. Otherwise, user134841's answer about calling into JavaScript is really the only alternative.

Resources