Inexplicable results with repeatable fr:autocomplete and xforms:delete

Posted by Ethan Gruber on
URL: https://discuss.orbeon.com/Inexplicable-results-with-repeatable-fr-autocomplete-and-xforms-delete-tp932322.html

I've looked through nabble and have not found this issue (bug?) addressed specifically.

I have a trigger that inserts a repeatable input.  The input uses fr:autocomplete to provide a list of suggests that are defined in the model (from Solr facets).

Here's the trigger:

<xforms:trigger appearance="minimal">
        <xforms:label>
            <img src="/apps/ead/images/add.gif"/>Subject</xforms:label>
        <xforms:insert ev:event="DOMActivate" context="." nodeset="./child::node()[last()]"
            origin="instance('subject-template')"/>
    </xforms:trigger>

Here's the input:

<xforms:repeat nodeset="subject">
        <div style="margin-bottom:10px">
            <!-- experimental: get subjects from solr index -->
            <fr:autocomplete ref="." dynamic-itemset="false" style="float: left;">
                <xforms:label>Subject</xforms:label>
                <xforms:itemset nodeset="instance('subjects-template')//lst[@name='subject']/int">
                    <xforms:label ref="@name"/>
                    <xforms:value ref="@name"/>
                </xforms:itemset>
            </fr:autocomplete>

            <xforms:trigger appearance="minimal">
                <xforms:delete ev:event="DOMActivate" nodeset="."/>
                <xforms:label>
                    <img src="/apps/ead/images/remove.gif"/>
                </xforms:label>
            </xforms:trigger>
        </div>
    </xforms:repeat>


Everything works fine with the trigger and the autocomplete until I delete one of the elements.  After I delete one element, the next time I initialize the xforms:insert trigger, an xforms:input is inserted that has no autocomplete information.  I have noticed this bug surfaces not only when I delete one of the "subjects," but also delete the parent node of "subject" and re-add its parent node.  If I look at the source of a working autocomplete input and an input inserted after a deletion in Firebug (for Firefox), there is an interesting difference.  Everything is identical down to the <div style="float:left">

HTML of input where autocomplete works:

<div class="yui-ac" style="float: left;">
  <span id="xf-2866$input·1-1" class="fr-autocomplete-input xforms-control xforms-input xforms-visited">
    <input id="xf-2866$input$xforms-input-1·1-1" class="xforms-input-input yui-ac-input" type="text" value="" name="xf-2866$input$xforms-input-1·1-1" autocomplete="off"/>
  </span>
  <div id="yui-gen5" class="fr-autocomplete-yui-div yui-ac-container">
    <div class="yui-ac-content" style="display: none;">
      ...autocomplete info: <ul>, etc....
    </div>
  </div>
</div>

HTML of input where autocomplete does not work, inserted after an xforms:delete is performed on a subject:

<div style="float: left;">
  <span id="xf-2866$input·1-2" class="fr-autocomplete-input xforms-control xforms-input xforms-visited">
    <input id="xf-2866$input$xforms-input-1·1-2" class="xforms-input-input" type="text" value="" name="xf-2866$input$xforms-input-1·1-2"/>
  </span>
  <div class="fr-autocomplete-yui-div"/>
</div>

You can see some differences here.  The top level div on the non-working input lacks the class "yui-ac."  The <input> lacks a class "yui-ac-input" and autocomplete="off".  The div which is supposed to contain the suggested options lacks the class "yui-ac-container" and contains no descendant content.

Any ideas?  Having an autosuggest functionality on repeatable elements is very important in my project, and it is equally important to be able to delete those elements and add more fluidly.

Any help is greatly appreciated.

Thank you,
Ethan Gruber





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