filamentgroup / ajax-include-pattern Goto Github PK
View Code? Open in Web Editor NEWAn Ajax-Include Pattern for Modular Content
Home Page: http://filamentgroup.com/lab/ajax_includes_modular_content/
License: MIT License
An Ajax-Include Pattern for Modular Content
Home Page: http://filamentgroup.com/lab/ajax_includes_modular_content/
License: MIT License
Like it says on the tin.
Bigger question though: is data-interaction a good feature to keep? I ask because it seems fairly simple to replicate in a custom setting, which comes with the benefit of retaining control over the actual events that trigger it, like...
$("[data-replace]").bind("click", function( e ){
e.preventDefault();
$(this).ajaxInclude();
});
Hi Scott et al,
Not an issue per say. But a question/request?
I may be missing something here, and if I am being a total newbie slap me with a wet fish and point me towards the nearest "Responsive Web 101" tuts.
I have, as you may have noticed from tweets, been toying with Ajax include and Lazy Loading over the pst couple of days. Having been pointed that way after asking @beep a rather newbie question like "you mean display:none; is a big no no, have I been doing responsive wrong for the past 9 months"
Anyway, to my point.
Lazy loading looks awesome, and will certainly solve a few issues I have been having with large assets, markup bloat and serving Javascript driven content (such as sliders and carousels) to devices that will never see it.
But the way I envisage using it long term means I shall probably be utilising the "data-media" aspect of it to have content pull in based on screen size. I may find I expend on this at a later date by using feature detection to hone the experience, but softly softly catchy monkey. This throws up a problem. Non-media query browsers, IE 8 in particular, will not receive the proper website experience as they will never pull in the content.
I know this is most likely the point, progressively enhance the experience. But I know my boss, and the client will prefer certain desktop aspects be common across all desktop browsers with a significant market share - Helllooooo IE 8.
Now that I have babbled, here is my question. Is there any way to enhance your wonderful creation Respond.js to give a helping hand to AjaxInclude? Maybe combine the two into some mega respond super power?! Or could you suggest an alternative approach?
I don't mind attempting the donkey work if you just point me in the right direction.
Thanks in advance ducks the flying wet fish
Dave
Hi there,
We noticed that your repo has a medium severity vulnerability:
Here is the test report for this repo.
If you’d like to fix this vulnerability, Snyk lets you generate a pull request that recommends the best upgrade path - there’s a link to fix this vulnerability on the test report.
Stay secure :-)
Snyk Community
This makes it difficult to manipulate the new content that has been inserted because it creates a race condition: at the time that the event is fired, the DOM has not yet been updated, so there is no guarantee that the DOM will have been updated by the time that any registered event handlers begin to run. (In my experience, the event handlers always run before the DOM has been updated.)
I forked the repo and starting working on a solution but I cannot think of one that doesn't involve changing the API. trigger
can't be called on an element that isn't in the DOM (which I'm assuming is why you forked that part of the code to trigger before updating for replaceWith
only), so there doesn't seem to be a way to have data-replace
trigger the event on the element itself like the other methods can.
Obviously I'm not exactly offering any answers here but I wanted to at least get a discussion going about this and see if @scottjehl or other curators of the library have an opinion about it.
Given three instances of the following:
data-append="-/ajaxsamples/slides-teases.html"
$("data-append").ajaxInclude()
adds the contents of slides-teases.html
to each element three times.
This is for a prototype, but it’d be amazing if it was a bit more context-aware.
I was just thinking about the impact on search engine optimisation as the vast majority of the page content would not be crawlable.
I don't think there will be an answer to this question, I guess it's the tradeoff here, so it's just a thought ..
There must be some way I'm thinking to work WITHIN the newly acquired (but very limited I suppose) javascript crawling abilities of the main search engines (it's fair enough to just care about Google though).
Any thoughts?
This URL in the repo description leads to a 404 error:
http://filamentgroup.com/lab/ajax_includes_modular_content/
I would love to see an option added to this which loads the content when the element is scrolled to a visible area within the viewport, similar to David Walsh's ScrollSpy class.
I think it might be possible to insert a portion of the target page:
<a data-replace="articles.php#related">Link to related articles</a>
Or something which is similar to jQuery load()
method.
The data-media attribute currently allows you to specify whether a media query for where an ajaxinclude should apply. It only works on initial load, though. It should also work when a previously invalid media query becomes valid.
This can be handled by binding to matchMedia's addListener, which is available as an extension here: https://github.com/paulirish/matchMedia.js/blob/master/matchMedia.addListener.js
Once an include is fetched, the triggering element's data- attribute should be removed.
So this is interesting: I removed the proxy argument, changing
$("[data-append], [data-replace], [data-after], [data-before]").ajaxInclude( "/quickconcat.php?wrap&files=" );
to
$("[data-append], [data-replace], [data-after], [data-before]").ajaxInclude();
And it would appear that the content from all my ajax-include
d elements is getting dumped into each element. (So if there are four stubs being pulled in, all four stubs get dumped into each element with a data-append
attribute.)
I am trying to test the library by using code from this demo: http://filamentgroup.github.io/Ajax-Include-Pattern/test/functional/default.html
I am linking to the js from the latest head and getting this error:
HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy Jquery.js:4:0
Also, what about Matchmedia and Matchmedia event listener? are these really dependencies too? I included them for now but I hope they are not dependencies too.
Thank you in advance,
Are there plans for/would you consider plans for a version of this awesome library that doesn't rely upon jQuery or the like, making it much more portable between various JS frameworks (or without one at all!)
Hi, this is a newbie question i am sure :)
My question is related to the demo /media.html basically if it is possible to not define the breakpoints inline?
Is there any way to define certain breakpoints on the whole document for an element that has a class, for example if an h2 has a class of .mobile instead of data-media="(max-width: 500px)":
Like this:
<h2 class="mobile" data-after="html/links.html">
<a href="html/links.html">Related External Links</a>
</h2>
And then in the script blow, all elements with a ".mobile" class has data-media="(max-width: 500px)" before the $( "[data-after]" ).ajaxInclude(); kicks in.
Pardon me for the way of explaining, as you can tell i am not an expert at this :)
Hope you can send me in the right direction.
Thanks.
Hello
http://filamentgroup.github.io/Ajax-Include-Pattern/test/functional/media.html
This mediaqueries-related demo is working when i use chrome and resize window on my desktop computer.
But when i'm viewing this page with my nexus 5, the third content is loaded !
Is it normal ? Anyone else get that problem ?
thx
If ajax-included HTML contains attributes for ajaxIncludes, those should work recursively.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.