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
****************************************************************





------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Xsltforms-support mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xsltforms-support

Reply via email to