Title: Polymer register all elements after my custom function
Tags: javascript;polymer-1.0;polymer-starter-kit
Question: I have  js file with this
var global_actions ={};
$(document).ready(function () {
myajaxcall(function(response){global_actions=response});
I have an elements with template :
<template&gt;
<h1&gt;{{global_actions.greetingtext}}</h1&gt;
</template&gt;
The problem is that template draw and init before global_actions=myajaxresponse;
What do i want
1.Call ajax and fill global_actions
2.Draw elements with databinding to global_actions data;
What i got elements draw before myahaxcall(callback);
Comment: your question is not clear.what do you mean with init?

Comment: So put this in template if..
I dont understand why you cant in the ajax change the value of this.myproperty??

Comment: sorry, but I dont understand your question, if you want to insert the element after the ajax you can use the template-if , or you can let the binding system work, and show your content after you receive the ajax response.

Comment: because i have 10 elements and i will not call the same function on all elements. i have one function that fill data for all elements in one global object. after its filled all elements read this object in ELEMENT.ready function.

Comment: Thanks #Alon
i found a solution Global variables :)
http://stackoverflow.com/questions/24867741/polymer-global-variables

Here is the accepted answer: First of all For ajax you can use the ajax component
https://elements.polymer-project.org/elements/iron-ajax
Second
let say you use dom-bind and the custom element that you want to put is on the main
var global_actions ={};
$(document).ready(function () {
myajaxcall(function(response){
//use app or this
app.isFinish = true;
app.response});
in the html write
<template is="dom-if" if="[[isFinish]]"&gt;
<custom-element some-data={{app.greetingtext}}&gt;</custom-element&gt;
</template&gt;
thus your element only render when you receive the response from server.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 5, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2016:00:02/02/16', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<javascript><polymer-1.0><polymer-starter-kit>', 'Title': 'Polymer register all elements after my custom function', 'ViewCount': 195, 'id': 35142727, 'user_AboutMe': None, 'user_AccountId': 6455593.0, 'user_DisplayName': 'Sergiy Tokarchuk', 'user_Reputation': 3.0, 'user_Views': 7.0, 'user_id': 5001124.0}}