Giter VIP home page Giter VIP logo

Comments (9)

WardCunningham avatar WardCunningham commented on May 28, 2024

To reproduce this bug one must look at the server-side rendering of a page. The client-side rendering (with view) works ok. Compare:

http://127.0.0.1:4567/indie-web-camp
http://127.0.0.1:4567/view/indie-web-camp

It has been a bit of a struggle to keep these two versions in sync.

from smallest-federated-wiki.

WardCunningham avatar WardCunningham commented on May 28, 2024

I'm still wanting to employ delegate() but have to reorganize the code a bit to make it work when internal links add new pages client-side.

from smallest-federated-wiki.

StevenBlack avatar StevenBlack commented on May 28, 2024

All events within a delegate container -- be they from new links or not -- bubble to the container and will be processed.

Therefore this is a code-ectomy, no server-side code required at all. This is as it should be, localizing client-side hover highlighting in the client.

Other upside: one $.delegate() call will handle hover events on potentially hundreds of action links, including those actions added later.

It's all-good.

from smallest-federated-wiki.

WardCunningham avatar WardCunningham commented on May 28, 2024

$(".journal").delegate(".action", "hover", ...

I hate to be dense. And I could just try this, but ...

It seems to me that this creates delegates for all the .journals in existence when the statement runs. If more .journals are created then delegate() will have to run again to pick them up. This could happen when sortable gets set up as it is a similar workflow.

This is made more confusing in that the "view" url routing is just a work-around for code that hadn't been written when you offered this commit.

from smallest-federated-wiki.

StevenBlack avatar StevenBlack commented on May 28, 2024

Ah, I wasn't aware this was a requirement.

Events bubble-up through the DOM so, at the limit, we could use $("body").delegate( ".action", "hover", .... )

Of course this won't be as efficient as selecting a more specific parent container but that's our catch-all.

If journals are smart, as I suspect they eventually will, then we could make them wire themselves, with something like $( this ).delegate( ".action", "hover", .... ) upon creation, or have a potential journal factory do it.

from smallest-federated-wiki.

WardCunningham avatar WardCunningham commented on May 28, 2024

I like the $("body") idea. I'm not opposed to having the dom work hard for us. In fact, since this is a global operation, that seems to be the right place to delegate from. If you revise it and check out all these cases, I'll pull it gladly. I'm also happy to do it too.

from smallest-federated-wiki.

WardCunningham avatar WardCunningham commented on May 28, 2024

resolved by be2e970

from smallest-federated-wiki.

FND avatar FND commented on May 28, 2024

I like the $("body") idea

FWIW, I believe $(document.body) is a little faster (a quick comparison confirms this - though it's barely significant).

resolved by be2e970

That commit is currently 404; did you perhaps forget to push?

from smallest-federated-wiki.

WardCunningham avatar WardCunningham commented on May 28, 2024

I attached the delegation to .main, the div around the pages.

(I thought it interesting that I could refer to a commit that I hadn't yet pushed. This simplified my workflow. However, there are drawbacks I hadn't considered. Might be time for a two-phase commit?)

from smallest-federated-wiki.

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.