Enhance html with Aurelia instead of Jquery


#1

I’ve developed a Django app that has a bunch of sloppy jquery sprinkled throughout. I’ve been thinking about refactoring it by replacing all of the jquery with Aurelia.

Does it make sense to replace Jquery with Aurelia to enhance html generated by a framework like Rails or Django?

Can you point me to some tutorials explaining how best to do this?

  • It’s not a single page app.

Thank you.


#2

There is a great post by @dwaynecharrington about that topic https://ilikekillnerds.com/2016/01/enhancing-at-will-using-aurelias-templating-engine-enhance-api/


#3

@zewa666 Thanks for the link. I read that article before, but I was concerned that it was over a year old. I was hoping for something more official from Aurelia about this.

I’ve used Aurelia to build a traditional SPA where I had Nginx serving static files and another server serving a rest api.

I guess my question could be better worded as… Is Aurelia suitable to replace Jquery in a RoR-like application where the server uses a template engine to create HTML documents? If so, how do you do it?

Normally, I would just use jquery to make ajax requests here and there and then write some spaghetti code to update the DOM. I would love to replace that with Aurelia components so I can take advantage of dating bindings and produce more testable code.


#4

The approach mentioned in the article is still valid. Core features do not break or change with Aurelia so there is an extremely high chance that old articles still have their meaning :slight_smile:

Back to your question though, it really depends. If your RoR app creates a prerendered page where you have to add a lot of functionallity and perhaps even take over the backend scenario by progressing furtheron as an SPA, it would be definitely worth bootstrapping Aurelia.

If its just for the sake to add a few simple widgets going to Vanilla WebComponents is maybe the better solution.
Earlier I used to do these things with Knockout and a lot of people recently value Vue for similar scenarios in the PHP world, but honestly sticking to pure WebComponents for small widgets is definitely the better way. Plus you can later on host them in an Aurelia app. It should be also quite easy to later on switch back to an Aurelia app if you see more requirements popping up.


#5

I found this section in the docs: http://aurelia.io/docs/fundamentals/app-configuration-and-startup#leveraging-progressive-enhancement.