// 単位 var taniData = jQuery.parseJSON('[{"tani":"\uff22\/\uff27","sort_no":"1"},{"tani":"\uff22\/\uff2c","sort_no":"2"},{"tani":"B\/S","sort_no":"3"},{"tani":"\uff22\/\uff38","sort_no":"4"},{"tani":"\uff23\/\uff32","sort_no":"5"},{"tani":"\uff23\/\uff33","sort_no":"6"},{"tani":"C\/T","sort_no":"7"},{"tani":"\uff24\/\uff2d","sort_no":"8"},{"tani":"\uff4b\uff47","sort_no":"9"},{"tani":"\uff30\/\uff27","sort_no":"10"},{"tani":"\uff30\/\uff2b","sort_no":"11"},{"tani":"\uff30\/\uff2c","sort_no":"12"},{"tani":"\uff32\/\uff2c","sort_no":"13"},{"tani":"\uff33\/\uff24","sort_no":"14"},{"tani":"\uff33\/\uff34","sort_no":"15"},{"tani":"\uff8d\uff9f\uff70\uff99","sort_no":"16"},{"tani":"\uff9b\uff70\uff99","sort_no":"17"},{"tani":"\u6a5f","sort_no":"18"},{"tani":"\u4ef6","sort_no":"19"},{"tani":"\u5f0f","sort_no":"20"},{"tani":"\u8eca","sort_no":"21"},{"tani":"\u672c","sort_no":"22"}]'); // 単位リスト作成 function openTaniWindow(retObj) { var parentObj = retObj.closest('[data-select-type="tani"]'); var btnObj = parentObj.find('.dropdown-toggle'); var dropdownId = btnObj.attr('id') + '_dropdown'; if (jQuery('#'+dropdownId).length < 1) { parentObj.append(''); var dialogHtml = '\ \ \ \ \ \ \
単 位
\
\ \ \ \
\
'; jQuery('#'+dropdownId).html(dialogHtml); } // 表示時処理 parentObj.on('show.bs.dropdown', function () { // リスト取得・反映 renderTaniList(taniData, retObj, '#' + dropdownId + ' .table-list>table>tbody'); }); parentObj.on('shown.bs.dropdown', function () { jQuery('#' + dropdownId + ' a:enabled').first().focus(); }); // 非表示時処理 parentObj.on('hidden.bs.dropdown', function () { btnObj.focus(); }); } // 単位リスト作成 function renderTaniList(data, retObj, listObjPath) { // リストへ反映 jQuery(listObjPath).empty(); jQuery.each(data, function(index, elem) { listHtml = '\ '+ jQuery.trim(elem.tani) +''; jQuery(listObjPath).append(listHtml); }); // 単位選択 jQuery(listObjPath + '>tr>td, ' + listObjPath + '>tr>td>a').on('click', function(event){ event.preventDefault(); var tani = $(this).closest('tr').find('td.tani').text(); retObj.val(tani).change(); }); }