tags:

views:

36

answers:

3

Is there any framework on which I can access the DOM when a user send the data back to the server? It would be useful for changing the page content using directly the DOM structure.

It would sound as a server-side javascript on which i could write document.getElementById.

+1  A: 

The DOM elements define the front-end. Your back-end should really not be concerned about the actual state of the UI elements on your page. You can re-render the whole page if necessary, or make AJAX requests passing JSON/XML around, but you really should only pass data back-and-forth, not DOM. That way you can encapsulate UI on the front-end (where it belongs) and free the back-end to worry about the other details of your application.

Justin Ethier
You are right, but imagine a simple scenario. Wouldn't it be nice to manipulate some DOM elements directly by the server side? ASP.NET have some features that help you to perform that task, but there isn't a full DOM-manipulation alternative?
maxxtack
I suppose, but you would have to use JavaScript in order to extract DOM elements for manipulation. So if you are going to do have to write client-side code anyway, what is the advantage to then shipping the DOM elements back to the server for processing instead of just manipulating them directly in the UI?
Justin Ethier
Ease of use and integration with the DB. By the way, i'm not planning to use it, it's just a curiosity :).
maxxtack
A: 

I was surfing yesterday looking for JS framework, and i found this one, check if you what are you looking for: http://itsnat.sourceforge.net/index.php?_page=overview

I guess it's what you are looking for...

Cesar
Going to check it, thank you.
maxxtack
A: 

Like Justin Ethier explained, it's good and easy to seperate them. Apart from that, JavaScript will never be on server-side. ;)

If you try to edit the Dom of a page on browser-side, it's great to use JavaScript Frameworks like Prototype, mootools, etc. (There are so much more of them, don't hesitate to use Google.)


Edit: You can combine the Dom editing features with Ajax.Request to let the server and browser talk. More infos you will find in the documentation of the frameworks out there.

Lemmi
"Apart from that, JavaScript will never be on server-side. ;)". What about node.js and Aptana Jaxer?
maxxtack
Here JavaScript uses AJAX to talk to the server. But the JavaScript source code is executed by the browser.
Lemmi
No, here we have client-side javascript (doesn't matter if it's using ajax) and server-side javascript, but I understood your point, thanks.
maxxtack
Yes. You're right too. But it's not natural to parse JavaScript on serverside. Especially when you take a look at features like the events or dom handling. ;)
Lemmi