Polymer JS:在 table 元素中加载时调用函数
PolymerJS : Calling function on load in table element
我想在迭代加载 table 单元格值时调用 searchByID():
这是我已有的,我想搜索数据库和 return ID 的值。 (这是由我的 searchByID() 完成的)我只关心它是如何呈现的
代码片段:
<template id="course-table-rows-template" repeat="{{item in response.entries}}">
<tr>
<td>
<a href="/#/course-details?lo_id={{item.id}}">{{item.id}}</a>
<form is="ajax-form" action="/add_to_wishlist?course_id={{item.id}}" method="get" id="add-course">
<button id="wishlist_add_button" on-click="{{handleWishlistClick}}">+ Wishlist</button>
</form>
</td>
<td>{{item.title}}</td>
<td>{{item.description}}</td>
<!--{{item.primary_category_id}}-->
<td>
<form is=""ajax-form" action="> How do I call the searchByID on load? I dont want to create a button and do an on click</form>
</td>
<td>{{item.primary_subcategory_id}}</td>
</tr>
</template>
我想做的:使用 item.primary_subcategory_id 查询数据库,并将该值放入 .
LMK 如果你需要更多的代码来解释。
您可以监听 domReady 事件。如果所有 dom 元素都准备好查询,它将被触发。有关 Polymer 活动的更多信息,您可以在 https://www.polymer-project.org/0.5/docs/polymer/polymer.html#lifecyclemethods
查看
我想在迭代加载 table 单元格值时调用 searchByID():
这是我已有的,我想搜索数据库和 return ID 的值。 (这是由我的 searchByID() 完成的)我只关心它是如何呈现的
代码片段:
<template id="course-table-rows-template" repeat="{{item in response.entries}}">
<tr>
<td>
<a href="/#/course-details?lo_id={{item.id}}">{{item.id}}</a>
<form is="ajax-form" action="/add_to_wishlist?course_id={{item.id}}" method="get" id="add-course">
<button id="wishlist_add_button" on-click="{{handleWishlistClick}}">+ Wishlist</button>
</form>
</td>
<td>{{item.title}}</td>
<td>{{item.description}}</td>
<!--{{item.primary_category_id}}-->
<td>
<form is=""ajax-form" action="> How do I call the searchByID on load? I dont want to create a button and do an on click</form>
</td>
<td>{{item.primary_subcategory_id}}</td>
</tr>
</template>
我想做的:使用 item.primary_subcategory_id 查询数据库,并将该值放入 . LMK 如果你需要更多的代码来解释。
您可以监听 domReady 事件。如果所有 dom 元素都准备好查询,它将被触发。有关 Polymer 活动的更多信息,您可以在 https://www.polymer-project.org/0.5/docs/polymer/polymer.html#lifecyclemethods
查看