<script> var forumlist = <?php echo xn_json_encode($forumlist_show);?>; // 初始化值,选中的值 var tagids = <?php echo xn_json_encode($tagids);?>; var action = '<?php echo $action;?>'; var jfid = $('select[name="fid"]'); var fid = <?php echo intval($fid); ?> || $('select[name="fid"]').val(); jfid.on('change', function() { var fid = jfid.val(); fid_on_change(fid); }); function fid_on_change(fid) { var s = ''; var forum = forumlist[fid]; $.each(forum.tagcatelist, function(k, tagcate) { s += '<select class="custom-select mr-1 mb-3 w-auto" name="tagid[]">'; s += '<option value=0>'+ tagcate.name +'</option>'; $.each(tagcate.taglist, function(k, tag) { s += '<option value='+ tag.tagid + (xn.in_array(tag.tagid, tagids) || (tag.tagid == tagcate.defaulttagid && action == 'selected') ? ' selected' : '') + '>'+ tag.name +'</option>'; }); s += '</select>'; }); $('#nav_tag_list_div').html(s); } fid_on_change(fid); $('#nav_tag_list_div').on('click', 'a.tag_option', function() { var jthis = $(this); var tagid = jthis.attr('tagid'); jthis.toggleClass('active'); // 隐藏域 var v = jthis.hasClass('active') ? tagid : ''; jthis.next().attr('value', v); }); // tag 选中区域。 </script>
把/plugin/xn_tag/hook/post_js.htm内容替换为以上内容即可。