ckan.js icon indicating copy to clipboard operation
ckan.js copied to clipboard

Undocumented dependency on JQuery?

Open davidmegginson opened this issue 9 years ago • 8 comments

Readme.md doesn't mention a JQuery dependency, but the library is failing when I don't have JQuery loaded.

davidmegginson avatar Sep 07 '15 21:09 davidmegginson

@davidmegginson are you using this from browser or node? In node should not require jquery.

rufuspollock avatar Sep 08 '15 09:09 rufuspollock

@rgrp I was using it in-browser, for a client-only app.

If that's the only JQuery dependency, then it might make sense to add a couple of extra lines of Javascript to do AJAX the old-fashioned way, and make the library standalone.

davidmegginson avatar Sep 08 '15 11:09 davidmegginson

@davidmegginson that's definitely a thought :-) - only trouble is that can be a little bit painful (e.g. if you need to add auth headers etc).

What's definitely missing right now is a something in the README about needing jquery - if you have a suggestion there please open a pull request or we can add it at our end :-)

Thanks for flagging this!

rufuspollock avatar Sep 09 '15 09:09 rufuspollock

I don't think this library should depend on jquery. Maybe there are smaller libraries made just for that purpose (AJAX).

letmaik avatar Oct 09 '15 11:10 letmaik

I agree with @letmaik - and in today's PR #34 proposed to use the lightweight needle-js library. Can we completely remove the need for jQuery, perhaps even abstract the Ajax call to allow the user to use whatever is already part of their stack?

loleg avatar May 01 '20 19:05 loleg

@loleg yes we can completely remove and also happy for us to use what is in people's stack - if there is a clean way to do that.

rufuspollock avatar May 04 '20 10:05 rufuspollock

On further thought, superagent is the only modern library with JSONP support (albeit undocumented), the reason I've been continuing to use jQuery in ckan-embed.

Would it potentially make sense to abstract away the HTTP request, so the library user can plug in whatever they want, with perhaps just a sensible default? If anyone with experience in the various options out there can weigh in here, please do.

loleg avatar May 05 '20 09:05 loleg

@loleg happy for you to lead here and make a proposal - if superagent seems good to you happy to go for that.

rufuspollock avatar May 05 '20 17:05 rufuspollock