Looking at Jaxer’s site, my initial concern was that you would end up with pretty poor code. Everyone with some experience probably has seen their fair share of HTML mixed with PHP, HTML mixed with ASP etc., and the examples on the site provided nothing else.
A new way to look at things
For someone like me who’s been doing a lot of work with PHP, wrapping your head around Jaxer’s ways seems a bit difficult. If you think of the MVC model for example, you would have a front controller which parses the request, calls a controller and then presents the view.
For loading files, Jaxer provides some file IO methods. You could use that to load some new HTML, but you can’t construct a new DOM document from that loaded code. If you could actually stick the newly loaded HTML into a separate document, you could achieve a separate view better. Currently you can just stick that code into an element in the document and then muck with it.
Simple MVC in Jaxer
I thought I’d need to give Jaxer some proper testing, so I wrote a simple MVC “framework”. It’s very simple, so that’s why the quotes. ;)
It has some basic functionality:
- Can display a master layout
- Lets you separate code to controllers and actions and calls them based on some URL parameters
- Has a basic “view” feature
So it’s really barebones, but it works and proves the point: Yes, you can actually bend Jaxer to MVC.
Please don’t bash the code too much; I wrote it pretty quickly! :D
I also added some commenting to it, to hopefully make it easier to understand.
I don’t see how a language like PHP would benefit from Jaxer-powered view layer as is suggested on their website, though.
I also think there could be a better approach than the MVC example I showed for making apps with Jaxer, since you now have good access to the DOM. What it is, I don’t know, not yet at least.
I have yet to see any “proper” website using Jaxer, but I think it is already feasible.