GWL (gdlAjax) replaces _both_ innerHTML and js-to-eval
Created by: genworks
As reported by Reinier van Dijk --- these should be separate conditionals, with separate conditional replacement code in the gdl-ajax.js javascript.
Imported comments:
By genworks on 2013-01-12 22:46:45 UTC
We need some examples of each combination. It seems to me that the js-to-eval needs to be evaluated any time the innerHTML is refreshed, whether or not the js-to-eval is actually dirty (i.e. :unbound) or not after the gdlAjax submission and associated fields are bashed and function is called. This is because the js-to-eval is typically intended for e.g. jQuery widgets which need to be initialized whenever the html is rendered.
This brings into question whether there is a real need for the js-always-to-eval ? When is that ever really necessary?
Note that in demos/newsite/, both of these are used. But after we look through some simple examples I have a feeling that we will determine that the js-always-to-eval is really redundant. Let's see where this goes.
By genworks on 2013-01-12 22:57:28 UTC
@reiniervandijk You may be interested to follow this Issue.
By reiniervandijk on 2013-01-15 12:25:41 UTC
Think of the opposite. If js-to-eval becomes :unbound, would you like to have :inner-html evaluated? No, you don't. In case of the SVG canvas, an :unbound js-to-eval (like add-line) will 'drag' the inner-html along with it right now, resulting in a new canvas being created every time. I think you need to clearly offer the user all capabilities that one would like to have. Suggestion:
- keep js-always-to-eval: this can be the initialization code if innerHTML changes. One may also call it js-on-init. Another option would be to define js-before-init AND js-after-init. Make sure to tell users that you typically expect static strings here, without dependencies.
- keep js-to-eval: this should normally be used for js that is dis-related to init events.
- compute js-all-to-eval with this logic:
- if both js-always-to-eval AND innerHTML :unbound AND js-to-eval :unbound, then
(string-append (the js-always-to-eval) (the js-to-eval))
- otherwise 1 on the 2, or none.
- if both js-always-to-eval AND innerHTML :unbound AND js-to-eval :unbound, then