pier-oliviert / observejs Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
i disabled xhr in observejs.js.coffee & wiped application.js.erb to ->
<%= yield %>
than work fine
Not sure what I want to do, the previous version wasn't perfect.
As of this moment, ObserveJS has an issue when storing DOM elements into JavaScript object. The problem is simple: When the user uses the 'back' button, the browser reload the HTML but doesn't restore JavaScript objects. That means that every state you had stored is wiped clean.
One scenario where this breaks my flow is when I deal with multiple steps that do not require a roundtrip to the server. What I do is I render all the steps and when the matching class is instantiated, I remove the extra steps from the DOM and store it in a variable. Here's an example:
ObserveJS.bind 'Messages', class
loaded: =>
@confirmation = @element().querySelector('div.confirmation').remove()
@on 'click', @element().querySelector('button'), @confirm
confirm: (e) =>
@element().appendChild @confirmation
This breaks as soon as you go back one page because the DOM doesn't have the confirmation element anymore and the class expect it to be there.
The idea would be to use to store DOM elements that are unecessary at page load. It should be possible to store DOM inside the template from any place in Rails' view hierarchy. Convention > configuration and all that.
<div as='Messages'>
<section class='step'>
<h2>First step. Select a user.</h2>
<ul>
<li>User 1</li>
</ul>
</section>
<%= content_tag :template, for: 'Messages' do %>
<section class='step'>
<h2>Second step. Something!</h2>
</section>
<% end %>
</div>
From that point, here's how you could implement this.
ObserveJS.bind 'Messages', class
loaded: =>
@on 'click', @element().querySelector('button'), @show
show: (e) =>
@element().appendChild(@retrieve('section.step'))
This last method would clone and cache that new step so if the user goes back, the DOM element is always present in the DOM via template.
Ok, this is long enough for now but I wanted to write all of this down so I can look back at this and edit it as/if I see problems.
As usual, if anyone has ideas, feel free to pitch in.
For some reason a script tag cannot be build by using "<script>".toHTML()
.
The function returns a script but it seems like it's not a HTMLScriptElement.
https://developer.mozilla.org/en/docs/Web/HTML/Element/script
There's an issue where Joint would create an instance when another one is already binded to an element. Such event would happen when an element is removed from the DOM tree and then re-inserted at a later time.
The previous version was to add a @element().on() method. I'm not entirely sure if this is the right approach.
This is polluting HTMLElement and it doesn't have any advantage.
https://encrypted.google.com/search?hl=en&q=jointjs
http://www.jointjs.com/
Might want to rename to avoid confusion.
I have a branch that should test coverage most of the library but it can't be merge in master because no headless browser I have tried worked.
The issue is that none of them supports MutationObserver
API and Ethereal is based off that. Even though all browser now supports it, emulators do not or other, like Phantomjs links against an old version of WebKit.
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.