dynlist.htm 897 B

1234567891011121314151617181920212223242526
  1. <%+cbi/valueheader%>
  2. <div>
  3. <%
  4. local vals = self:cfgvalue(section) or {}
  5. for i=1, #vals + 1 do
  6. local val = vals[i]
  7. if (val and #val > 0) or (i == 1) then
  8. %>
  9. <input class="cbi-input-text" value="<%=pcdata(val)%>" onchange="cbi_d_update(this.id)" type="text"<%=
  10. attr("id", cbid .. "." .. i) .. attr("name", cbid) .. ifattr(self.size, "size") ..
  11. ifattr(i == 1 and self.placeholder, "placeholder", self.placeholder)
  12. %> /><br />
  13. <% end end %>
  14. </div>
  15. <script type="text/javascript">
  16. cbi_dynlist_init(
  17. '<%=cbid%>', '<%=resource%>', '<%=self.datatype%>',
  18. <%=tostring(self.optional or self.rmempty)%>
  19. <%- if #self.keylist > 0 then -%>, [{
  20. <%- for i, k in ipairs(self.keylist) do -%>
  21. <%-=string.format("%q", k) .. ":" .. string.format("%q", self.vallist[i])-%>
  22. <%-if i<#self.keylist then-%>,<%-end-%>
  23. <%- end -%>
  24. }, '<%: -- custom -- %>']<% end -%>);
  25. </script>
  26. <%+cbi/valuefooter%>