天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

學習YUI.Ext第七日-View&JSONView Part Two-一個畫室網站的案例

之前在Part 1簡單介紹了Veiw和JSONView。今天這里小弟為大家說說應用的案例,原本Jack的Image Chooser是一個非常好的案例,當中包含Jack大量的奇技淫巧,不過正因為這樣,過于深奧,小弟我亦不能全盤吃透,只挑其“勃大莖深”之處,與君共勉之!
本文包含四大知識點:1.在LayoutDialog中加入Tabs;2.View的使用方式;3.JSONView的使用方式;4.獲取XML/JSON的fields值與分頁

演示地址

View之定義
  A View is generally used to build a quick template-based display of datamodel, rather than building a more complex grid. I thnk there's a blog post that illustrates doing this with JSON data. Templates can be used for any repetitious html creation, not necessarily tied to a datamodel.
主要的意思是View用于展示DataModel的數據,Part 1已經說過。這里是來自fourm某君的補充。

代碼點評:

1.先看一段簡單的

	//用yui.ext做翻轉按鈕, super easy(美工最愛!?^^)showBtn = getEl('showIntro');showBtn.on('click', this.showDialog, this, true);showBtn.applyStyles("cursor:pointer");showBtn.on('mouseover', function(){showBtn.dom.src='images/over_10.gif'}, this, true);showBtn.on('mouseout', function(){showBtn.dom.src='images/btn_10.gif'}, this, true);

//左邊動畫效果,createDelegate()負責輪換效果var luo=getEl("left_pic");luo.move('right', 250, true, .1, function(){  luo.dom.src='images/'+who+".gif";  luo.move('left', 250, true, .15, null, YAHOO.util.Easing.easeOutStrong);}.createDelegate(this));

2.在LayoutDialog中加入Tabs

LayoutDialong分兩個區域:west & center。而center之中我們要加入tabs,并逐一附加active的事件

			var center = layout.getRegion('center'); var tab1 = new YAHOO.ext.ContentPanel('luo', {title: '羅老師作品'}); center.add(tab1); center.add(new YAHOO.ext.ContentPanel('chen', {title: '陳老師作品'})); 
//center.on('panelactivated',function(){// alert(center.titleTextEl);//}, this, true);//center.showPanel('center'); /*two ways to activate the tabs.and tabs= many CPs如果在BasicDialog中,只需要dialog本身就可以獲取getTabs,因為Dialog本身就是唯一的一個Region;但在LayoutDialog中,Region是多個的,所有要指明哪個一個Region才行*/
// stoe a refeence to the tabs 獲取TABS集合var tabs = layout.getRegion('center').getTabs();//逐一加入事件tabs.getTab('center').on('activate', function(){this.show_thumb('student')}, this, true);tabs.getTab('luo').on('activate', function(){this.show_thumb('luo')}, this, true);tabs.getTab('chen').on('activate',function(){this.show_thumb('chen')}, this, true); //center.showPanel('chen'); //用Region激活也可以/*Tips:不能立即激活事件,會點延時,經過多行代碼的延時便ok !用addbufferlistener理論上也可以*/layout.getRegion('center').getTabs().activate('center');

3.View的使用方式

//XML:index方式訪問字段;JSON:直接使用字段名var tpl = new YAHOO.ext.Template( 	'<div class="thumb">'+	'<div><img onclick=popupDialog("userfiles/image/'+who+'/{0}",{2},{3}) '+	' src=userfiles/image/lite_'+who+'/{0}></div>' + 	'<div>文件大小: {1}</div>'+	'</div>'); tpl.compile(); //“編譯DOM”加速var schema = {	tagName: 'row',//Item項	id: 'id',//ID如不需要時,設置空白字符串,不能取消!	fields: ['filename','filesize','width','height']//讀取的字段};var dm = new YAHOO.ext.grid.XMLDataModel(schema);var mainView = new YAHOO.ext.View('pic_'+who, tpl,dm, {	singleSelect: true,//If JSON,還需指定一個config:jsonRoot	emptyText : '<div style="padding:10px;">沒有匹配的內容!</div>'}); dm.on('load',function(){}, this, true); mainView.on('click', function(vw, index, node, e){	//alert('Node "' + node[] + '" at index: ' + index + ' was clicked.')},this, true);mainView.prepareData = function(data){	// prepare,用于自定義格式	//如JSON方式直接屬性名訪問,e.g data.sizeString = formatSize(data.size);	data[1] = formatSize(data[1]);	return data;};//用DataModel加載文件,如果是JSONView,這個服務由JSONView本身(UpdateManager)提供dm.load('xml.ASP?who='+who);	

4.JSONView的使用方式

var dh = YAHOO.ext.DomHelper; dh.append(document.body, {tag: 'div', id: 'editUserDialog-user'}); //XML:index方式訪問字段;JSON:直接使用字段名var tpl = new YAHOO.ext.Template('Username: {username}' + 'Birthday: {birthday}' + 'Member Since: {join_date}' + 'Last Login: {last_login}'); tpl.compile(); var mainView = new YAHOO.ext.JsonView('pic', tpl, {  singleSelect: true,  jsonRoot: 'user',  emptyText : 'No images match the specified filter'}); mainView.load("test.ASP", "id=2"); //JSONView特有的異常事件mainView.on('loadexception', function(){onLoadException()}, this, true);var onLoadException= function(v,o){	 alert('Error'); };

5.獲取XML/JSON的fields值與分頁

這兩個問題放在一起討論的原因是至今我還不能實現。如果按照jack的辦法:

mainView.on('click', function(vw, index, node, e){	alert('Node "' + node.id + '" at index: ' + index + ' was clicked.');});
可得到index但node.id無法獲取。我只好用較丑陋的方式實現:
//在Domhelper中“硬”輸出click事件var tpl = new YAHOO.ext.Template( 
'<div class="thumb">'+
'<div><img onclick=popupDialog("userfiles/image/'+who+'/{0}",{2},{3}) '+
' src=userfiles/image/lite_'+who+'/{0}></div>' +
'<div>文件大小: {1}</div>'+
'</div>'
);

分頁:
View的分頁視乎應該通過DataModel。但我沒成功過。如知道緣由的朋友懇請告之。
http://www.ajaxjs.com/yuicn/article.ASP?id=20070239

JavaScript技術學習YUI.Ext第七日-View&amp;amp;JSONView Part Two-一個畫室網站的案例,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 亚洲AV成人无码999WWW | 亲嘴扒胸摸屁股视频免费网站 | 亚洲黄色成人 | 久久久无码精品亚洲A片猫咪 | 亚洲无人区码二码三码区别图 | 蜜芽资源高清在线观看 | 亲胸吻胸添奶头GIF动态图免费 | 老太脱裤子让老头玩xxxxx | 2021国产精品久久久久精品免费网 | 99国内精品久久久久久久清纯 | 欧美日韩国产在线一区二区 | 国产精品久久人妻拍拍水牛影视 | 国产午夜精品久久久久婷婷 | 国精产品一区一区三区有限 | 黄色三级网站在线观看 | 草莓AV福利网站导航 | 92午夜理论第1000集 app | 九九99亚洲精品久久久久 | 免费在线视频a | 云南14学生真实初次破初视频 | 日日色在线影院 | 成人AV无码一二二区视频免费看 | 高h 纯肉文 | 高清国语自产拍在线 | 国产强奷糟蹋漂亮邻居在线观看 | 亚洲呦女专区 | 老师洗澡让我吃她胸的视频 | black大战chinese周晓琳 | 亚洲 欧美 国产 综合不卡 | 老师xxxx69动漫 | 国产日韩精品一区二区在线观看 | 欧美人与善交大片 | 成人毛片18岁女人毛片免费看 | 亚洲VA天堂VA欧美VA在线 | av无码在线日本天堂 | 97影院理论午夜伦不卡偷 | 男女无遮挡吃奶gift动态图 | 乐乐亚洲精品综合影院 | 欧洲精品一区二区不卡观看 | 日本丝袜护士 | 成人在线免费观看 |