10

I am working in ExtJS 4.I have been getting stuck at a point where I have to create a hyperlink in ExtJS 4.I have been searching a lot for creating hyperlink in ExtJS 4 but I did not get any solution for it.Actually I have to create a hyperlink and after clicking on that link I am going to display another page in ExtJS 4. Actually also i did not get the event in ExtJS 4. How can I use hyperlink in ExtJS 4. I am using this way...

{
      xtype: 'panel',
      html:'<a href="second.js">Second page</a>',
}  

Please give me some suggestions.....

Althaf PJ
  • 15
  • 4
Pravin Mane
  • 529
  • 4
  • 13
  • 25

2 Answers2

29

I'd use an autoEl for this.

{
    xtype: 'component',
    autoEl: {
        tag: 'a',
        href: 'http://www.example.com/',
        html: 'Example.com'
    }
}

Here's a Fiddle

Johan Haest
  • 4,391
  • 28
  • 37
  • thanks for your reply.But I want to display another page in extjs4.Is it possible to display it? – Pravin Mane Mar 18 '13 at 13:46
  • ExtJS is single page, what do you mean with the next page? – Johan Haest Mar 18 '13 at 13:47
  • Actually I want to display another page which is designed in extjs4 in same application.I dont want to move to another web site – Pravin Mane Mar 18 '13 at 13:50
  • Well isn't it just calling another URL in your application? Image the starting app to be on `localhost/index.html` then your second page would be `localhost/second.html` I think you're making this harder than it is. Do you need to pass variables to the 2nd page? – Johan Haest Mar 18 '13 at 14:00
  • It is not required to pass variable to second page.I just want to display another page which is designed in extjs4.Is it possible to do it?and path is not changed "localhost/index.html" it remains same.. – Pravin Mane Mar 18 '13 at 14:34
  • So basically you want to load another ExtJS application on the same page. Check the following url for what you're trying to achieve: http://www.sencha.com/forum/showthread.php?129236-Best-practice-for-multiple-Application-objects-on-one-page However, ExtJS is made for 1 app per page. I recommend you just make another html page or something with your 2nd application and load that page. – Johan Haest Mar 18 '13 at 15:43
1

You can also use the html property of a label component and call a controller function from there. Example:

{xtype: 'label',
html: 'bla bla? <a href="#" onClick="javascript:appName.app.getController(\'myController\').showRegistration();">Register</a>'
}
tonymayoral
  • 4,797
  • 2
  • 26
  • 27