BorisMoore / jsrender

A lightweight, powerful and highly extensible templating engine. In the browser or on Node.js, with or without jQuery.

Home Page:http://www.jsviews.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jsrender does not show data in select - options

yedduprasasd opened this issue · comments

Boris, First off let me thank you for the awesome features you have made available via jsRender. For a novice like me in Web Development, it is a great and simple method to build apps.

I have a very simple need to display list of Company IDs for the user to select from. The list is a "select" and I have been able to successfully populate the template and can see the data in the consol.log. However when I render the template at the place holder, the list does not show any options.

There is a class called "chosen-select" on the select tag that is part of the html template I bought and this gives me the right look and feel. If I remove this class, the list is populated, but I am missing out the functionality and look and feel I wish to keep.

How can I continue to use the class and still be able to use jsrender to populate the list.

Below is the code...

---- Placeholder ----
<div class="col-sm-4">
  <select id="companylistplaceholder" class="form-control m-b chosen-select" name="account">              
  </select>
</div>

---- Template ----
<script id="companylisttemplate" type="text/x-jsrender">
  <option>[%>id%]</option>
</script>

---- Icon when clicked calls the AJAX function that intern calls a postgreSQL function via django to get the list of company IDs ----
<div class="ibox-tools">
  {% for imodulesaccess in lmodulesaccess %}
    {% if imodulesaccess.createallowed == 'Y' %}
      <a class="plus-link"><i id="i_adduser"class="fa fa-plus text-navy" data-toggle="modal" data-target="#adduser"></i></a>
    {% endif %}
  {% endfor %}
</div>
---- call to the ajax function ---
$("#i_adduser").click(function(ev){
  getcompanylist();
})

---- AJAX function that calls the Db and get the data ----
    function getcompanylist(){
      $.ajax({
        type: "GET",
        url: "/elahadmin/getcompanylist",
        data: {},
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(lcomanylist){
            console.log(lcomanylist);
            var template = $.templates("#companylisttemplate");
            var companylistdata = template.render(lcomanylist);
            $("#companylistplaceholder").html(companylistdata);
            console.log(companylistdata);
        }
      })
    }

OptionIssue.txt

It seems like JsRender is functioning correctly, and your issue is not coming from JsRender at all.

It looks like you are using other technologies for generating content - some kind of server rendering with templates? I don't know what the {% %} and [% %] markup relates to.

If changing a class makes the options show up, then your issue involves CSS styles - presumably a CSS stylesheet containing "chosen-select" - and associated with the "HTML template you bought". Again, the issue would be with this rather than with JsRender.

I'll close this as not being a JsRender issue or bug. Please add comments if you have further questions that do concern JsRender usage directly... Thanks...