ExtJS4.1 ExtJS TabPanel Double-click the label to close the page

Source: Internet
Author: User

/* Always feel that the close button generated by TabPanel is too small
It's not easy to close, so I want to double-click the tab to make it easier.
So I found the following code on the Internet
url:http://atian25.iteye.com/blog/413920
But used in my system framework is not valid, I use the ExtJs4.1.
I don't know if it's my problem, but I can't find the wrong one.
So I thought of a way to pro-test support ExtJs4.1
It could be a bit of a hassle, but there's no way I can find the problem.
*///////////////////---Below is the method of online search I am invalid------//////////////////// [JavaScript]View Plaincopy
  1. var tabs = New Ext.tabpanel ({
  2. Renderto: ' tabs1 ',
  3. WIDTH:450,
  4. activetab:0,
  5. Frame:true,
  6. Defaults:{autoheight: true},
  7. items:[
  8. {contentel:' script ', title: ' Short Text '},
  9. {contentel:' markup ', title: ' Long Text '}
  10. ],
  11. Initevents: function () {
  12. Ext.TabPanel.superclass.initEvents.call (this);
  13. This.on (' Add ', this.onadd, this , {target: this });
  14. This.on (' Remove ', this.onremove, this , {target: this });
  15. This.mon (this.strip, ' MouseDown ', This.onstripmousedown, this );
  16. This.mon (this.strip, ' ContextMenu ', this.onstripcontextmenu, this );
  17. if (this.enabletabscroll) {
  18. This.mon (this.strip, ' MouseWheel ', This.onwheel, this );
  19. }
  20. //add:monitor title Dbclick
  21. This.mon (this.strip,' DblClick ',This.ontitledbclick, this);
  22. },
  23. //add:handler
  24. Ontitledbclick:function (e,target,o) {
  25. var t = this.findtargets (e);
  26. if (t.item.fireevent (' BeforeClose ', T.item)!== false) {
  27. T.item.fireevent (' close ', t.item);
  28. This.remove (T.item);
  29. }
  30. }
  31. });


-----Here is my method--------useful to Viewport only posted TabPanel code [JavaScript]View Plaincopy < param name= "wmode" value= "Transparent" >
    1. {
    2. Xtype: "TabPanel",
    3. Region: "center",
    4. ID: "tabpanel",
    5. MINTABWIDTH:100,
    6. Listeners: {
    7. ' tabchange ': function () {
    8. }
    9. }
    10. }
I'm dynamically generating tab, so I'm going to write this down. Notice the code inside. [JavaScript]View Plaincopy
  1. var createtab=function (id,title,url) {
  2. var tabs = ext.getcmp ("TabPanel");
  3. For (var i = 0; i < tabs.items.length; i++) {
  4. if (tabs.items.items[i].title = = title) {
  5. Tabs.items.items[i].show ();
  6. return;
  7. }
  8. }
  9. var newtabpanel= ext.create (' Ext.panel.Panel ', {
  10. Layout: ' fit ',
  11. Title:title,
  12. Collapsible: true,
  13. Closable:id==0? false:true,
  14. AutoScroll: false,
  15. Initevents: function () {
  16. var obj = this ;
  17. var id = ' tab-' + (this.id.split ('-') [1]-1 + 2) + '-btnwrap ';
  18. Ext.get (id). Dom.ondblclick = function () {
  19. if (obj.title!=' My Workbench ')
  20. Tabs.remove (obj);
  21. }
  22. },
  23. HTML: ' <iframe name= ' mainframe "width=" 100% "height=" 100% "frameborder=" 0 "src=" ' +url+' "></iframe > '
  24. });
  25. Tabs.add (Newtabpanel). Show ();
  26. }
[JavaScript]View Plaincopy < param name= "wmode" value= "Transparent" >
    1. Use the following code to test the Add tab
    2. Createtab ("0", "My Workbench", " myhome.htm");
    3. Createtab ("1", "account Management", " user.htm");
more 0
    • Next Extjs4.1 checkboxgroup dynamic generate checkbox and checkbox-bound point-click event

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.