polymer

HowTo add a required indicator to paper-input

只愿长相守 提交于 2019-12-10 09:54:26
问题 Given the paper-input <paper-input floatingLabel label="Type only numbers... (floating)" validate="^[0-9]*$" error="Input is not a number!"> </paper-input> How do I add some indication that the field is required to the user. 回答1: From the core-input docs https://github.com/Polymer/core-input/blob/master/core-input.html AFAIK paper-input extends core-input therefore this should apply here too: core-input also can optionally validate the value by providing it with a regular expression to match

How do I wrap tinyMCE inside a polymer element?

℡╲_俬逩灬. 提交于 2019-12-10 09:53:39
问题 So I'd like to create a polymer-element that usually just displays content, but when the edit-attribute is present then tinymce should appear inline. This is what I have so far: <polymer-element name="article-widget" attributes="edit"> <template> <div id="content"><content></content></div> </template> <script> Polymer('article-widget', { edit: false, ready: function() { tinymce.init({ selector: "div#content", theme: "modern", plugins: [ ["advlist autolink link image lists charmap print

Data binding for dynamically generated HTML in Polymer?

陌路散爱 提交于 2019-12-10 09:42:37
问题 When I write the following inside my <template> -tag, everything works fine: <ul id="breadcrumbList" class="breadcrumb"> <li><a on-click="{{breadcrumbClick}}">{{overviewName}}</a></li> </ul> I dynamically generated a new <li> -element of the same structure, like this: crumb = document.createElement("li"); crumb.innerHTML = '<a on-click="{{breadcrumbClick}}">'+category+'</a>'; But when I click this element, the event-handler isn't called. The event-handler looks like this: breadcrumbClick:

Iron-ajax Data binding

人走茶凉 提交于 2019-12-10 06:27:30
问题 How to data bind in the new Polymer v1.0? I saw an answer in polymer iron-ajax : How to Bind data from input element to iron-ajax's body attribute But it did not help me and Here is my code <dom-element id="test-app> <template> ... <iron-ajax auto url="https://www.googleapis.com/youtube/v3/search" params="{{ajaxParams}}" handleAs="json" lastResponse="{{response}}" method='GET'> </iron-ajax> </template> </dom-module> Script Polymer({ is:"Test-app", properties: { qry: { type: String, value:

How do I write condition in polymer1.0 with “dom-if”?

让人想犯罪 __ 提交于 2019-12-10 04:04:55
问题 I have below code: <template is="dom-if" if="{{item.hasAttach}}"> <i class="fa fa-paperclip"></i> </template> item.hasAttach = true/false But I want to check condition in this if like : item.content_format_code == 'PDF' <template is="dom-if" if="{{item.content_format_code == 'PDF'}}"> <i class="fa fa-pdf"></i> </template> <template is="dom-if" if="{{item.content_format_code == 'JPEG'}}"> <i class="fa fa-jpg"></i> </template> <template is="dom-if" if="{{item.content_format_code == 'xls'}}"> <i

Where to download all polymer elements as zip file?

时光毁灭记忆、已成空白 提交于 2019-12-10 03:58:01
问题 Polymer 1.0 is released recently and I can download the elements à la carte at the elements.polymer-project.org site, but I can't find an easy link to download everything in one big zip file? Any idea where they are hiding it? 回答1: You can download the Polymer Starter Kit for beginners that includes almost all the elements. And download the missing elements as a ZIP file as suggested here. Missing elements: Google Web Components Gold Elements 回答2: If you are using bower run these commands:

Polymer 1.0: Does <iron-meta> support binding to dynamic variables?

倖福魔咒の 提交于 2019-12-10 03:41:58
问题 I can get my <iron-meta> instance to work properly when using a static value. But when I bind the value to a dynamic variable (using {{}} ) it <iron-meta> no longer behaves as expected. Does <iron-meta> support binding its value to dynamic variables? <iron-meta id="meta" key="info" value="foo/bar"></iron-meta> // works <iron-meta id="meta" key="info" value="{{str}}"></iron-meta> // fails Previous work This question is a refinement of this question in order to clarify that the ONLY thing

polymer unit test mocking dependencies

☆樱花仙子☆ 提交于 2019-12-10 03:38:35
问题 Im just starting on polymer. Im trying to unit test a custom element that has dependencies and I would like to fake/mock these out. I've found Scott Miles recommendation on how to mock the core-ajax implementation. I thought I could follow that pattern easily but this only works as long as my element does not import the about to be mocked (core-ajax in this case) element. If it does import it, then when the test tries to run I get 'Uncaught NotSupportedError: Failed to execute

Polymer: when to use async?

自闭症网瘾萝莉.ら 提交于 2019-12-10 02:36:46
问题 What's the purpose of async method in polymer? When should I use it? Right now I'm using it like hm-this-bug-is-kinda-weird-maybe-async-will-fix-it-yep-id-did-yey . It does not give me any confidence in my code as I'm sprinkling async just when some timing bug shows up. 回答1: The answer is slightly different here depending on whether you're using Polymer 0.5 or 1.0. In 1.0, more operations are synchronous, so you may not see quite as much need for async (also, the async method works slightly

Polymer if-template with filter: filter not updating

不想你离开。 提交于 2019-12-09 23:22:16
问题 I am using an if-template to show or hide items in a list, within a Polymer-element. My template is based on a list of values, and filtered using a reference list. Updating the list of values yields the desired effect. However, changing the filter reference list (here removing one element) does not yield an update of the template. <!DOCTYPE html> <html> <head> <script src="//cdnjs.cloudflare.com/ajax/libs/polymer/0.2.3/platform.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs