PDA

View Full Version : [SOLVED] Link or button from TBAR to open a new window



s2xi
14 May 2010, 3:40 AM
Hey guys, so I know this much either be extremely easy or just not practical because I can't find ANY examples or tutorials that do what I want to do.

The only thing I've found is links opening up a new window from the Ext js but nothing from the js itself opening a new window from a function within int.

So I have a tbar and i have text: 'Settings' and also html:'
<a href="javascript:void(0);" onClick="showWindow()">Show Window</a>'

I created my window function showWindow() to do win.show() so this should work right?

I also tried to add a handler to this....but I'm at the point where I'm thinking that text fields with embedded html links won't work right?

do i need to use the button: [..] for this work?

this is my code


tbar: new Ext.Toolbar({
enableOverflow: true,
items: [{
xtype:'tbtext',
text: '<div id=/"timeDate/" style=/"display: block;/"></div>'
},'->',{
xtype: 'tbtext',
html: "<div class='barlinks'>Welcome, <? echo $_SESSION['user_name']; ?></div>"
},'-',{
text: 'Settings',
//handler: winPanel.show()
//html: '<a href="javascript:void(0);" onClick="showWindow();">Show Window</a>'
},'-',{
xtype: 'tbtext',
bodyStyle: 'padding: 5px',
html: '<a class="links" href="logout.php">Logoff</a>'
}]

Rothariger
14 May 2010, 3:50 AM
i dont understand the question...

i will use the handler option...

CrazyEnigma
14 May 2010, 7:26 AM
I am assuming you want to open a new browser window and not a Ext JS window.



handler: function (button, evt)
{
// Ye old Javascript never fails
window.open(<your href>);
}

s2xi
14 May 2010, 2:11 PM
um i want to open a new ext.window() when the user clicks on the settings link. I don't know if i should make it a button, or a text link with a handler function.

I tried the handler thing, but maybe i'm just not understanding its correct usage. I can't seem to make it open something like

new Ext.window({...});

CrazyEnigma
14 May 2010, 2:40 PM
Well, handler is the way to go. But I would suggest using an iframepanel. The iframepanel is an item of the Ext.Window.

s2xi
14 May 2010, 2:47 PM
why an iframepanel? well, no its not far off from what i was thinking.

since i'm not very good in ExtJS yet my solution was have a new Ext Window pop up and just load my settings.php in there via iFramePanel like you mentioned. I'm not sure yet how to use JSON and PHP yet so this was my current option.

so I'm just stuck trying to open a new window if a window is not open already to make a new one, if it is open to hide it with a close button. or something like that.

the way i made the new window functions would work.

how would i use the handler approach to open a new Ext window?

CrazyEnigma
14 May 2010, 6:59 PM
If it is your settings for your application, then I would not use iframes, because of information transfer between iframes.



handler: function(button, evt)
{
var win = new Ext.Window({
<your config>
});
win.show();
}


You need to set a delegate function to the handler, not the function you want to call.

s2xi
15 May 2010, 12:35 AM
WOW!!!

THANK YOU THANK YOU THANK YOU!!!

I have been trying to do this for ages! I know its simple, but I just started playing with ExtJs and I'm learning one thing at a time. THis is something that I haven't fully grasped yet, using the handler function. My next thing to learn is the listener: action.

I know how to make components outside of my application, but when I'm integrating them directly i.e. using the handler function something that I haven't learned the syntax yet.

thanks alot

CrazyEnigma
15 May 2010, 10:59 AM
If this is SOLVED, then I suggest you edit your original post and append a [SOLVED] in front of your post.