티스토리 뷰
개발을 하다보면 코드테이블에서 코드값을 불러와 <select>로 만들어주는 일이 허다하다.
좀 개발을 편하게 하기 위해 아래처럼 만들어 놓고 쓰면 편하다..
<select id="returnCode">
</select>
$.es.getCodeList($('#returnCode'), '003', '선택');
$.es={};
$.fn.extend($.es,{
getCodeList: function($obj, kind, first){
$obj.empty();
if(first && first.length>0)
$obj.append($.validator.format('<option value="">{0}</option>',first));
$.ajax({ method:"POST"
, url: '/common/codeList'
, data: {kind: kind}
, success : function(data){
$.each(data.list, function(idx, item){
$obj.append( $.validator.format('<option value="{0}">{1}</option>', item.code, item.name) );
})
}
, error : function(xhr, status, error){
alert("error");
}
});
}
});
스프링 Controller 부분
@RequestMapping("/common/codeList")
public @ResponseBody Map<String, List> codeDivList() throws Exception{
return commonCode.getCodeList();
}
Service 부분
public Map<String, List> getCodeList(Code form){
List<Code> codeList = get("codeList");
List<Code> resultList = new ArrayList<Code>();
Map<String, List> codeMap = new HashMap<String, List>();
for(Code codeDomain : codeList){
if(codeDomain.getKind().equals(form.getKind())){
resultList.add(codeDomain);
}
}
codeMap.put("list", resultList);
return codeMap;
}
'jquery' 카테고리의 다른 글
jquery masonry (0) | 2017.12.28 |
---|---|
[jquery 그리드] 데이타 테이블 적용방법 - DataTables is a plug-in for the jQuery Javascript library (0) | 2017.06.21 |
[jquery] radio 버튼 체크여부 알아보기 (0) | 2017.06.12 |
[jquery, javascript, html] 자바스크립트에서 radio undefined 체크하기 (0) | 2017.06.12 |
jquery disabled readonly 하는 방법 (0) | 2017.06.09 |
- Total
- Today
- Yesterday
- 포인터
- xe addon
- 이클립스
- 파이썬
- ocjap
- XE3
- 프로씨
- ocajp
- webix
- 플러터
- C언어
- proc
- XE
- EC
- 오라클
- 인포믹스
- Python
- xe애드온
- JDBC
- esql
- MySQL
- 라이믹스 모듈
- 문자열
- php
- 자바
- 파싱
- 스크래핑
- C
- KG
- 자바 smtp
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |