Re: [Xsltforms-support] Setting node value in javascript
Brought to you by:
alain-couthures
From: Mark S. <m_s...@ma...> - 2012-07-15 19:25:05
|
Michael, Thanks for the suggestion, and I take your point. What I really need is a custom control. My JS function just takes a value chosen by a user when they select a feature on a map (openLayers vector layer), and pops the value into an XML instance. So, logically what I have is a select1 rendered as a map with selectable features. The features are already represented as XML (gml), rendered by openLayers as points on my map. So, yes, you are right, I am trying to do something with Javascript that I should be doing with just XForms! Best wishes Mark On 15 Jul 2012, at 19:46, C. M. Sperberg-McQueen wrote: > > On Jul 15, 2012, at 5:50 AM, Mark Seaborne wrote: > >> Hi, >> >> I have noticed that if I change the form so that the js function is called from an XForms control using xf:load AND I add a bind to the model, then the XForms UI updates to reflect the value change caused by the js function. >> >> However, when the function is triggered elsewhere in the page, the UI is not updated, even with the bind statement in the model. >> > > I have not yet studied any of the examples you sent, but stepping > back a bit, at a very high level it looks as if you are doing (or: trying > to do) things in Javascript that you could in theory do in XForms; > making that work will always require that you know a lot about the > internals of the XForms implementation. > > I wonder if you would make more headway doing less in JS and > more in XForms -- define your function as a Javascript function that > operates solely on its arguments and calculates a result, and > register your function as an XPath function along the lines shown > in http://en.wikibooks.org/wiki/XSLTForms/XSLTForms_only_Extensions#User-Defined_Functions > -- then set the value of the node you want to update using the > XForms setvalue action, and use XForms events to tie updates to > the value to whatever triggering events are taking place elsewhere. > > Concretely, I don't think "Javascript function f has been invoked" > or "... has completed execution" are events that appear in the XForms > model. Various user actions, changes to values on specified nodes, > and so on are events XForms knows about and I bet you'll have more > luck getting XSLTForms to do what you want if you pose your problem > in terms of those elements. > > Of course, if you've already got a lot of non-XForms Javascript in > the app, this approach may seem impracticable. > > Just my two cents ... > > Michael Sperberg-McQueen > > -- > **************************************************************** > * C. M. Sperberg-McQueen, Black Mesa Technologies LLC > * http://www.blackmesatech.com > * http://cmsmcq.com/mib > * http://balisage.net > **************************************************************** > > > > |