Select2 "No Matches found" on XPAGES partial update -
i have downloaded demos.nsf , try learn select2 http://www.bootstrap4xpages.com/bs4xp/demos.nsf/select2.xsp
everything run have found problem select2 didn't trigger xpages server side event when return "no matches found"
here how produce problem :
- i have input hidden , computed text binding document datasource
- i have button partial update computed text
- that input hidden used select2 scriptblock
- run xpages
- type name (e.g. patrick) , select name
- click button , computed text display selected name
- type keyword "qqqqqqq" , select2 results "no matches found"
- click button again, , computed text "blank"
- redo number 6 dan 7 again, , computed text still "blank" , didn't display "patrick" name
how solve problem ?
here code :
<xp:inputhidden id="inputhidden1" value="#{document1.coba}"/> <xp:scriptblock id="scriptblock4"> <xp:this.value><![cdata[ x$( "#{id:inputhidden1}" ).select2({ placeholder: "find someone", minimuminputlength: 2, quietmillis: 300, width: '300px', allowclear : true, ajax: { url: "namesdatastore.xsp", datatype: 'json', data: function (term, page) { return { q: term, // search term page_limit: 10 }; }, results: function (data, page) { // parse results format expected select2. return data; } }, initselection: function(element, callback) { //sets default value (if value selected previously) var id = $(element).val(); //if value selected: perform ajax call retrieve text label if (id !== "") { $.ajax( "namesdatastore.xsp", { data: { id: id }, datatype: "json" }).done(function(data) { callback(data); }); } } }); ]]></xp:this.value> </xp:scriptblock> <xp:text escape="true" id="computedfield1" value="#{document1.coba}"> </xp:text> <xp:button value="refresh" id="button2" styleclass="btn btn-success"> <i class="glyphicon glyphicon-ok " /> <xp:eventhandler event="onclick" submit="true" refreshmode="partial" refreshid="computedfield1"> </xp:eventhandler> </xp:button>
Comments
Post a Comment