Closed MrDys closed 12 years ago
Original reporter: jrochkind
jrochkind: Believe this is no longer relevant.
jrochkind: bullk change, pushing past 3.1 in preperation for 3.0.
jrochkind: Just brainstorming some more, but maybe ideally the JS shouldn't be sniffing/parsing/rewriting URI's at all, but a better design would be to have it recognize current state by looking at HTML classes (or HTML5 data-* attributes), and getting new URLs from response returned by the server on an ajaxy post to the add/remove actions. That might lead to simpler and more robust code than continuing to sniff and modify URLs as strings from the DOM but adding regex.
jrochkind: [the server could even just return an HTML snippet for "new folder button" that the JS just drops into place, so the JS doesn't need to know anything about URLs, the JS just makes the POST and then gets back the new HTML for the button in it's now correct state]
CODEBASE-278: The folder handling code in application.js examines and rewrites URLs on a form action. But the code assumes that the app is mounted at the HTTP root '/' path, it looks for and sets URLs that it assumes always begins "/folder".
When in fact a Rails app can be at some other prefix, "/demo/folder" in my case, or whatever, "/path/to/my/blacklight/folder"
The JS code should be fixed to work regardless.
This can be done if the js code simply looks at the existing form=action, and uses regexp matches on just the tail end of it, or to search and replace just the tail end of it, etc.
Additionally, the JS code to do an ajax form submit doesn't need to be looking through the inputs and constructing a query string by hand, it can just call form.serialize() and pass the results as the 'data' argument to jQuery.post.