Answer the question
In order to leave comments, you need to log in
How to attach select2 to smarty?
Hello, can anyone tell me how to properly tie select2 to smarty?
The template looks like this
<div class="fel">
<label for="{$v.depending.caption2}">{$v.depending.name2}{if $v.depending.required2==1}<span class="mandatory"> *</span>{/if}{if $v.info_message} <a href="javascript:;" class="info_icon tooltip" title="{$v.info_message}" >i</a>{/if}</label>
<select disabled='disabled' name="{$v.depending.caption2}" id="{$v.depending.caption2}" {if $v.depending.no>2}onchange="selDepending(2, '{$v.depending.caption2}', '{$v.depending.caption3}', '{$v.depending.id}', 0, {if $v.other_val}1{else}0{/if}, '{$lng.general.other}', {if $v.all_val}1{else}0{/if}, '{$lng.general.all}', '{$live_site}', 'dep_id_{$v.depending.caption1}')"{else}{if $v.other_val}onchange="checkOther(this.form.{$v.depending.caption2}, '{$v.depending.caption2}')"{/if}{/if} {if in_array($v.depending.caption2, $gmaps_unique)}onblur="autoLocator_{$gmaps_fields[$v.depending.caption2]}();"{/if} >
<option value="">{$v.depending.top_str2}</option>
</select>
<input type="hidden" name="dep_id_{$v.depending.caption2}" id="dep_id_{$v.depending.caption2}" value="" />
{if $v.other_val}
<span id="span_{$v.depending.caption2}_other_val" style="margin-left: 10px; display: none;">
<input type="text" name="{$v.depending.caption2}_other_val" id="{$v.depending.caption2}_other_val" value="{if isset($tmp[$v.depending.caption2])}{$tmp[$v.depending.caption2]}{/if}"/>
</span>
{/if}
{if $v.depending.no>=3}
</div>
<select disabled='disabled' class="chzn-select" name="{$v.depending.caption2}" id="{$v.depending.caption2}" {if $v.depending.no>2}onchange="selDepending(2, '{$v.depending.caption2}', '{$v.depending.caption3}', '{$v.depending.id}', 0, {if $v.other_val}1{else}0{/if}, '{$lng.general.other}', {if $v.all_val}1{else}0{/if}, '{$lng.general.all}', '{$live_site}', 'dep_id_{$v.depending.caption1}')"{else}{if $v.other_val}onchange="checkOther(this.form.{$v.depending.caption2}, '{$v.depending.caption2}')"{/if}{/if} {if in_array($v.depending.caption2, $gmaps_unique)}onblur="autoLocator_{$gmaps_fields[$v.depending.caption2]}();"{/if} >
<option value="">{$v.depending.top_str2}</option>
</select>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://site.ru/autot/chosen.jquery.js"></script>
<script>
$(".chzn-select").chosen();
</script>
Answer the question
In order to leave comments, you need to log in
Read the documentation for smart since you have to use it
https://www.smarty.net/docsv2/ru/language.function...
there is html_options there.
then see that the html code is assembled in the correct form.
And only then connect to the page chosen
When inserting javascript into a template, you can do without framing it in a literal.
To do this, you need to carefully work with curly braces.
space { space , since the letter must not stick to space }
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question