<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    szhswl
    宋針還的個(gè)人空間

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

    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的數(shù)據(jù),Part 1已經(jīng)說過。這里是來自fourm某君的補(bǔ)充。

    代碼點(diǎn)評(píng):

    1.先看一段簡(jiǎn)單的

    //用yui.ext做翻轉(zhuǎn)按鈕, 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);
    

    //左邊動(dòng)畫效果,createDelegate()負(fù)責(zé)輪換效果
    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分兩個(gè)區(qū)域: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,因?yàn)镈ialog本身就是 唯一的一個(gè)Region; 但在LayoutDialog中,Region是多個(gè)的,所有要指明哪個(gè)一個(gè)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:不能立即激活事件,會(huì)點(diǎn)延時(shí),經(jīng)過多行代碼的延時(shí)便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項(xiàng)
    id: 'id',//ID如不需要時(shí),設(shè)置空白字符串,不能取消!
    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,還需指定一個(gè)config:jsonRoot
    emptyText : '<div style="padding:10px;">沒有匹配的內(nèi)容!</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,這個(gè)服務(wù)由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值與分頁(yè)

    這兩個(gè)問題放在一起討論的原因是至今我還不能實(shí)現(xiàn)。如果按照jack的辦法:

    mainView.on('click', function(vw, index, node, e){
    alert('Node "' + node.id + '" at index: ' + index + ' was clicked.');
    });
    
    可得到index但node.id無法獲取。我只好用較丑陋的方式實(shí)現(xiàn):
    //在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>'
    );

    分頁(yè):
    View的分頁(yè)視乎應(yīng)該通過DataModel。


    本文轉(zhuǎn)自:http://www.ajaxjs.com/yuicn/article.asp?id=20070239

    ---------------------------------------------------------------------------------------------------------------------------------
    說人之短,乃護(hù)己之短。夸己之長(zhǎng),乃忌人之長(zhǎng)。皆由存心不厚,識(shí)量太狹耳。能去此弊,可以進(jìn)德,可以遠(yuǎn)怨。
    http://m.tkk7.com/szhswl
    ------------------------------------------------------------------------------------------------------ ----------------- ---------
    posted on 2007-12-08 19:13 宋針還 閱讀(427) 評(píng)論(0)  編輯  收藏 所屬分類: EXT
    主站蜘蛛池模板: 免费高清在线影片一区| 亚洲一区二区在线免费观看| 日本高清免费不卡在线| 性生大片视频免费观看一级| 国产成人亚洲精品播放器下载| 亚洲色大成网站www久久九| 亚洲成a人一区二区三区| a级特黄毛片免费观看| 国产成人无码免费看片软件 | 国产一区二区三区免费在线观看| 在线观着免费观看国产黄| 国产禁女女网站免费看| 99在线免费观看视频| 久久国产精品免费看| 性生大片视频免费观看一级| 亚洲精品视频免费| 国产性生大片免费观看性| 国产免费拔擦拔擦8X高清在线人| 全免费a级毛片免费看| 97视频免费观看2区| 无人在线直播免费观看| 97人妻精品全国免费视频| 欧洲人免费视频网站在线| 2021精品国产品免费观看| 中文字幕免费在线看| 日韩精品免费视频| 最近中文字幕完整免费视频ww | 免费一级毛片在级播放| 亚洲国产一区视频| 亚洲视频免费一区| 日韩国产免费一区二区三区| 麻豆国产VA免费精品高清在线| 全部免费毛片在线| 亚洲高清国产拍精品26U| 亚洲午夜精品一区二区公牛电影院| 亚洲日本久久久午夜精品| 日日狠狠久久偷偷色综合免费| 国产午夜成人免费看片无遮挡| 国产成人精品免费视频网页大全| 久久久久久久综合日本亚洲| 亚洲伊人久久综合影院|