PDA

View Full Version : Ajax History support



Hani
15 Aug 2007, 12:45 PM
I've ported the yahoo history browser to ext. Many of the changes were culled from various forum posts (eg, getting rid of document.writes), and I removed the yahoo dependency so it now works with any ext adapter. Is this useful to anyone? I can uploaded it to the ux area in the wiki if anyone thinks it's worthwhile.

Documentation is from yahoo: http://developer.yahoo.com/yui/history/

Just replace every YAHOO.util.History with Ext.ux.History.

JorisA
16 Aug 2007, 3:44 AM
Wow awesome! I was looking for this. I'll give it a try!

Hani
16 Aug 2007, 4:24 AM
There's a small bug in it btw, just comment out the two 'fireEvent' lines and it should all work. I'll upload a new version soon.

mdissel
16 Aug 2007, 4:25 AM
Is this useful to anyone? I can uploaded it to the ux area in the wiki if anyone thinks it's worthwhile.



Very useful and some small samples in the wiki ux area will help people who are not familiar with the Yahoo.history component!

Thanks
Marco

jon.whitcraft
16 Aug 2007, 7:24 AM
I agree this should be put in the wiki.

Ronaldo
16 Aug 2007, 9:54 AM
If this works, that would be great! Would you mind adding this to the user extensions?

One (small) remark: Maybe the name Ext.ux.History is a little too general. I'd vote for something like 'Ext.ux.BrowserHistory', as more and more user extensions are popping up, avoiding duplicate names for different things might be something to think about.

But hey, that's just me. Again, thanks for your work and sharing this with us!

16 Aug 2007, 9:58 AM
If this works, that would be great! Would you mind adding this to the user extensions?

One (small) remark: Maybe the name Ext.ux.History is a little too general. I'd vote for something like 'Ext.ux.BrowserHistory', as more and more user extensions are popping up, avoiding duplicate names for different things might be something to think about.

But hey, that's just me. Again, thanks for your work and sharing this with us!

i second this suggestion.

Thank you so much for your work and contribution.

Gavin
19 Aug 2007, 9:56 AM
Please keep going! I could definitely use something like this :-)

mdelanno
14 Oct 2007, 2:04 AM
A nice article on this topic : http://weblogs.asp.net/bleroy/archive/2007/09/07/how-to-build-a-cross-browser-history-management-system.aspx

crafter
14 Oct 2007, 3:01 AM
Thank you. This is a great addition.

gendronb
16 Oct 2007, 9:32 AM
Great work indeed,

But I'm unable to catch the history manager's load event in order to get the application's current state.

I first tried a variation based on the syntax proposed by Yahoo :


Ext.ux.History.onLoadEvent.subscribe( function(), blablabla...

but I get the following error:


Ext.ux.History.onLoadEvent has no properties...

I the tried something like :


Ext.ux.History.on('load', function (), blablabla...

but this doesn't seem to catch anything...

Thanks for your help...

jo2008
21 Nov 2007, 5:40 AM
Ext.ux.History.onLoadEvent... is yahoo syntax.


Ext.ux.History.on('load', function (), blablabla... works if you register the load event correctly in the Ext.ux.History class.
I did it like this:
Add this function in the Ext.apply() section:


makeEvent: function()
{
this.addEvents({"load": true});
},


Then call it right at the end of the file:


Ext.ux.History.makeEvent();


Then you'll get the load event correctly..

gendronb
21 Nov 2007, 7:22 AM
Hi jo2008,

Thanks for your help...

However, it's not working for me. The history load event still doesn't get fired...

The following code is declared in a script block inside the header :



var myModuleBookmarkedState = Ext.ux.History.getBookmarkedState('indicator');
var myModuleInitialState = myModuleBookmarkedState || '1';

function myModuleStateChangeHandler(state) {
switchIndicator(state);
};

Ext.ux.History.register('indicator', myModuleInitialState, myModuleStateChangeHandler);

Ext.ux.History.on('load', function () {
alert('history manager loaded...');
var myModuleCurrentState = Ext.ux.History.getCurrentState('indicator');
});

Then, the following statement is called inside a script block in the body:



Ext.ux.History.initialize();

Am I missing something?

BTW, there was already an addEvents statement inside the initialize function...

jo2008
21 Nov 2007, 7:45 AM
Well I know that there's an addEvent in the intialize function, but I think initialize is only called after I try to register the event...
So I added the event manually and got it working..

What I do differently as in the yahoo introduction is the body tag thing.. i made it a function, because otherwise the initialzie was called before my other ext functions which I AJAXed at another time than the HTML is called.



<body>
<script type="text/javascript">
function initHistory()
{
Ext.ux.History.initialize();
};
</script>


I then call the initHistory() manually after I'm sure I registered everything..


Oh, I changed another thing.. a previous post said, that 2 fireEvent lines should be commented out, because they were bugs..
After that, nothing fires the event.. that might be your problem :D

I did this at the end of the initialize function


Ext.onReady(_initialize);
_initialized = true;
this.fireEvent("load", this);



Jo



Oh, btw.
Have you by any chance multiple modules registered? because I'm having serious trouble with that..

gendronb
21 Nov 2007, 8:05 AM
Hi Jo!

Wonderful, it works now! You were right, the problem was with the missing fireEvent.

Thanks, you definitely made my day!

About registering multiple modules, I must admit I never tried...

--
Bruno

jo2008
21 Nov 2007, 8:16 AM
Cool :-)
Did you manage that without the ugly makeEvent thing?


The multiple module problem I have is also a bug in the history script... i think I already found it but have to test it first..

Jo

temporary
22 Nov 2007, 4:06 PM
Does this work with Ext 2.0?

jo2008
22 Nov 2007, 11:55 PM
Yes it does... I would propose to start a new thread in the Ext 2.0 extension forum... though that wouldn't favor the search for the latest sources..