ORBEON.xforms.Document.setValue updates field but not instance

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

ORBEON.xforms.Document.setValue updates field but not instance

maryjane
Hi there

My form field is bound to an instance and when i enter data manually it updates the instance correctly.

But when I jquery to populate the field. This only half works as it does populate the actual form field but does not change the underlying instance.

If i enter then field and just hit space bar after the jquery inserted text it will then update but not when the jquery inserts the data

This the js called in the jquery document ready function I am using (focus() used for testing purposes).

$(".myinput").focus(function() {
    var myId = $(this).attr('id');
    alert("i am trying to update " + myId);
    ORBEON.xforms.Document.setValue(myId, "test");
    });

Can anyone see what I am doing wrong?
Reply | Threaded
Open this post in threaded view
|

Re: ORBEON.xforms.Document.setValue updates field but not instance

Alessandro  Vernet
Administrator
See below a full example where this works, in span mode (now the
default in nightly builds). Note that the id you must use in the
setValue() is the id of the XForms control. This is the id you have on
<xforms:input>, if you have one, and otherwise one is generated for
you. The id of the HTML input is different, at least in span mode.

<xhtml:html
        xmlns:ev="http://www.w3.org/2001/xml-events"
        xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
        xmlns:xforms="http://www.w3.org/2002/xforms"
        xmlns:xhtml="http://www.w3.org/1999/xhtml"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:xxforms="http://orbeon.org/oxf/xml/xforms">
    <xhtml:head>
        <xforms:model>
            <xforms:instance>
                <instance/>
            </xforms:instance>
        </xforms:model>
        <xhtml:script type="text/javascript">
            $(function() {
                $(".myinput input").focus(function() {
                   var myId = $(this).closest('.xforms-control').attr('id');
                   ORBEON.xforms.Document.setValue(myId, "test");
               });
            });
        </xhtml:script>
    </xhtml:head>
    <xhtml:body>
        <xforms:input ref="." class="myinput"/>
    </xhtml:body>
</xhtml:html>

Alex

On Fri, Apr 20, 2012 at 4:45 AM, maryjane <[hidden email]> wrote:

> Hi there
>
> My form field is bound to an instance and when i enter data manually it
> updates the instance correctly.
>
> But when I jquery to populate the field. This only half works as it does
> populate the actual form field but does not change the underlying instance.
>
> If i enter then field and just hit space bar after the jquery inserted text
> it will then update but not when the jquery inserts the data
>
> This the js called in the jquery document ready function I am using (focus()
> used for testing purposes).
>
> $(".myinput").focus(function() {
>    var myId = $(this).attr('id');
>    alert("i am trying to update " + myId);
>    ORBEON.xforms.Document.setValue(myId, "test");
>    });
>
> Can anyone see what I am doing wrong?
>
> --
> View this message in context: http://orbeon-forms-ops-users.24843.n4.nabble.com/ORBEON-xforms-Document-setValue-updates-field-but-not-instance-tp4573645p4573645.html
> Sent from the Orbeon Forms (ops-users) mailing list archive at Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws
>


--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet