dwz jui 표 데이터 매개 변수 전달 클릭 시 동적 input 추가

2551 단어
/**dwz.csstable.js
 * Theme Plugins
 * @author [email protected]
 */
(function($){
	$.fn.extend({
		cssTable: function(options){
			var op = $.extend({scrollBox:"tableList", parent:$(document)}, options);
			return this.each(function(){
				var $this = $(this);
				var $trs = $this.find('tbody>tr');
				if (!$this.parent().hasClass(op.scrollBox)){
					var lh = $this.attr('layoutH');
					$this.removeAttr('layoutH');
					$this.wrap('<div class="'+op.scrollBox+'"'+ (lh ? ' layoutH="'+lh+'"' : '') +'></div>');
				}
				
				$trs.hover(function(){
					$(this).addClass('hover');
				}, function(){
					$(this).removeClass('hover');
				}).each(function(index){
					var $tr = $(this);
					if (index % 2 == 1) $tr.addClass("trbg");
					
					$tr.click(function(){
						$trs.filter(".selected").removeClass("selected");
						$tr.addClass("selected");
						var sTarget = $tr.attr("target");
						if (sTarget) {
							if ($("#"+sTarget).size() == 0) {
								op.parent.prepend('<input id="'+sTarget+'" type="hidden" />');
							}
							$("#"+sTarget).val($tr.attr("rel"));
						}
					});
					
				});
				
			});
		}
	});
})(jQuery);
// navTabTodo
	$("a[target=navTabTodo]", jParent).each(function(){
		$(this).click(function(event){
			var $this = $(this);
			var url = $this.attr("href").replaceTmById(jParent);
			DWZ.debug(url);
			if (!url.isFinishedTm()) {
				alertMsg.error($this.attr("warn") || DWZ.msg("alertSelectMsg"));
				return false;
			}
			var title = $this.attr("title");
			if (title) {
				alertMsg.confirm(title, {
					okCall: function(){
						navTabTodo(url, $this.attr("callback"));
					}
				});
			} else {
				navTabTodo(url, $this.attr("callback"));
			}
			event.preventDefault();
		});
	});
replaceTmById:function(_box) {
			var $parent = _box || $(document);
			return this.replace(RegExp("({[A-Za-z_]+[A-Za-z0-9_]*})","g"), function($1){
				var $input = $parent.find("#"+$1.replace(/[{}]+/g, ""));
				return $input.size() > 0 ? $input.val() : $1;
			});
		},
		isFinishedTm:function(){
			return !(new RegExp("{[A-Za-z_]+[A-Za-z0-9_]*}").test(this)); 
		},

좋은 웹페이지 즐겨찾기