Giter Club home page Giter Club logo

Comments (16)

mabar avatar mabar commented on September 27, 2024 1

Oh so there is a pre-built version https://naja.js.org/#/installation?id=from-a-cdn-or-a-local-file

It is just not mentioned in quick start and tutorial sections, @jiripudil

from application.

jahudka avatar jahudka commented on September 27, 2024 1

@dg I think he's right on that - imagine how you'd feel if you came across something like this for the first time:

  • "Hey, we proudly present to you this amazing backend framework!"
  • "One of the cool features it has is X. To use X, you can pick from any of these three 3rd party solutions:"
    • <last commit 5 years ago>
    • <abandoned>
    • <only possibly viable candidate>

I don't know about you, but when I run across something like this, the state of the third party integrations heavily influences how I feel about the main thing, because obsolete / abandoned integrations (that are still the recommended way of doing things) often signify that either that specific feature or the entire project aren't really used all that much - so if I want to rely on the feature or the project I might be setting myself up for an unpleasant surprise a couple of years down the road.. I don't think you need to take it personally, it didn't read as an intent to attack or insult from my point of view, just an observation (and in my opinion a correct one at that).

from application.

n0nag0n avatar n0nag0n commented on September 27, 2024 1

Just throwing this out there for AJAX related stuff, I have used htmx on a couple projects and it's actually amazing. I used it with Latte in fact and rendering out template partials was trivial. This may be specific to another discussion, but thought it may be relevant to discuss in here.

from application.

n0nag0n avatar n0nag0n commented on September 27, 2024 1

No, I didn't use the Nette framework to integrate it, however it is easy to build a bridge to handle JSON requests through events in htmx. I know this is crappy jQuery but just to illustrated the point.

$(function() {
	$('body').on('htmx:afterRequest', function(event) {
		if(event.detail.xhr.getResponseHeader('content-type') == 'application/json') {
			var json = $.parseJSON(event.detail.xhr.responseText);
			if("some_var" in json) {
				// fetch a Nette Snippet
			}
		}
	});
});

In the response, you actually can render partials out that can be "injected" into different parts of the page. See this example to see what I mean. I typically do oob-swap for instance if I return a response of a table with a bunch of rows I'm updating, but I have a <div class="flash-message">Some message</div> that I wanted injected to show a flash message as well.

from application.

matronator avatar matronator commented on September 27, 2024 1

@xpavp03
Just a shameless plug, but have you tried Axette? It's a lightweight easy to install alternative for AJAX handling with no dependencies (so it works even without jQuery).

from application.

mabar avatar mabar commented on September 27, 2024

So problems are that docs recommend no longer maintained Nittro and Naja does not have a pre-built version? Naja works great and since there were no BC breaks in ajax on Nette side, the outdated nette.ajax.js should work (and it does) just as fine.

from application.

dg avatar dg commented on September 27, 2024

Well, if the only problem is that the „AJAX & snippets“ page lacks mention of embedding Naja in the page via <script>, I'm happy to add it there. But you could skipped the reputation-hurting bullshit, right?

from application.

mabar avatar mabar commented on September 27, 2024

@jahudka Would you mind notifying others on slack and forum that you no longer plan to maintain Nittro? Most people simply don't know project needs help and there are still some pretty big projects that depend on it and may be able to help with development.

from application.

dg avatar dg commented on September 27, 2024

@jahudka oh heck, there was a link to an awesome well-maintained library (as first) and link to Nittro. No reason to write essays here about Nette's reputation suffering. All he (or You) had to do was create an issue that Nittro is unmaintained and should be removed, or just click edit and remove the link. I'm really not going to read this stuff because of a link someone historically put in the doc.

from application.

xpavp03 avatar xpavp03 commented on September 27, 2024

Oh so there is a pre-built version https://naja.js.org/#/installation?id=from-a-cdn-or-a-local-file

Sorry, I missed that.

I read the Install and set up Naja page, and got scared off by the need for npm.

Also, the page says I need to use a module bundler and goes on to reference Webpack and a need for a Nette extension. Although I wasn't 100% sure from the wording that snippets wouldn't work without the Nette extension, all of this together just felt like too much additional work compared to simply linking some form of nette.ajax.js just like we do with netteForms.min.js.

So, are you saying that I can just link to the CDN built and I'm good to go without any additional libraries or extensions? I wish this was more explicit in Naja's docs.

At some point nette.ajax.js in the past years stopped working for me and after checking back now, and seeing the documentation still referencing invalidateControl() instead of redrawControl(), I didn't assume it would work.

from application.

jahudka avatar jahudka commented on September 27, 2024

@mabar yeah, I should probably do that.. I honestly didn't even know Nittro is still being used - I get maybe one or two questions a year on the Nittro forum and I know of only one large project which afaik still uses it in production, but I think that project is in the process of transitioning to a different solution. So I didn't realise I need to make some kind of statement - I simply didn't think anyone cares at this point.

@dg yeah, you have a point, sorry.

from application.

xpavp03 avatar xpavp03 commented on September 27, 2024

I'd like to point out that my post wasn't only about removing a link from the docs.
It was mainly about the (unnecessary) complexity of (now the only) officially recommended library. Somehow this got lost in the heated discussion.

from application.

mabar avatar mabar commented on September 27, 2024

What is unnecessary complex about Naja except the setup docs which could be easily fixed? I don't see much that could be simplified, an official library would be probably almost identical.

from application.

xpavp03 avatar xpavp03 commented on September 27, 2024

@n0nag0n Thanks for sharing. Did you write something that made it work with Nette snippets (JSON with fixed structure that contains HTML, flashes etc.)?

from application.

eydun avatar eydun commented on September 27, 2024

@matronator Axette is looking good. Could be nice, if it was possible to install it from Packagist/Composer.

from application.

matronator avatar matronator commented on September 27, 2024

@matronator Axette is looking good. Could be nice, if it was possible to install it from Packagist/Composer.

Thanks! I don't think that would be possible, as Axette is a JavaScript library and Composer is only for PHP as far as I know. I could theoretically create some proxy package in PHP that would automatically install Axette as part of its composer install workflow, but it would be difficult to determine where to install it as every project is different. Besides I don't think anyone does that and it would certainly be non-standard.

Sorry for going off-topic, just wanted to reply.

Although, why not use Axette as an inspiration for the "native" Nette AJAX library? It is lightweight with zero dependencies and has only the necessary features without extra bloat.

from application.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.