autoComplete: Serenity theme layout.js bug on removing item
See original GitHub issueDescribe the defect Remove an item from the p:autoComplete multiple select is not working. It throws an error:
components.js.xhtml?ln=primefaces&v=10.0.0&e=10.0.0:3 Uncaught TypeError: c.attr is not a function
at c.removeItem (components.js.xhtml?ln=primefaces&v=10.0.0&e=10.0.0:3)
at HTMLSpanElement.<anonymous> (layout.js.xhtml?ln=serenity-layout:818)
at HTMLUListElement.dispatch (jquery.js.xhtml?ln=primefaces&v=10.0.0&e=10.0.0:2)
at HTMLUListElement.v.handle (jquery.js.xhtml?ln=primefaces&v=10.0.0&e=10.0.0:2)
I have to manually change the serenity-layout/layout.js with temporary fix shown in the codes below.
if(PrimeFaces.widget.AutoComplete) {
PrimeFaces.widget.AutoComplete.prototype.setupMultipleMode = function() {
var $this = this;
this.multiItemContainer = this.jq.children('ul');
this.inputContainer = this.multiItemContainer.children('.ui-autocomplete-input-token');
this.multiItemContainer.hover(function() {
$(this).addClass('ui-state-hover');
},
function() {
$(this).removeClass('ui-state-hover');
}
).click(function() {
$this.input.focus();
});
//delegate events to container
this.input.focus(function() {
$this.multiItemContainer.addClass('ui-state-focus');
$this.jq.addClass('md-inputwrapper-focus');
}).blur(function(e) {
$this.multiItemContainer.removeClass('ui-state-focus');
$this.jq.removeClass('md-inputwrapper-focus').addClass('md-inputwrapper-filled');
setTimeout(function() {
if($this.hinput.children().length == 0 && !$this.multiItemContainer.hasClass('ui-state-focus')) {
$this.jq.removeClass('md-inputwrapper-filled');
}
}, 150);
});
var closeSelector = '> li.ui-autocomplete-token > .ui-autocomplete-token-icon';
this.multiItemContainer.off('click', closeSelector).on('click', closeSelector, null, function(event) {
if($this.multiItemContainer.children('li.ui-autocomplete-token').length === $this.cfg.selectLimit) {
if(PrimeFaces.isIE(8)) {
$this.input.val('');
}
$this.input.css('display', 'inline');
$this.enableDropdown();
}
//$this.removeItem(event, $(this).parent()); //<---- Original Serenity code which cause the error
$this.removeItem($(this).parent()); //<-- temporary fix
});
};
};
Environment:
- PF Version: 10.0.0
- JSF + version: Mojarra 2.3.9
- Affected browsers: ALL
To Reproduce
- Download serenity-2.1.1.zip from PrimeStore and add Serenity theme to project
- Create autoComplete like below example
Example XHTML
<p:autoComplete id="organization-list" value="#{orgView.organizations}" completeMethod="#{orgView.onOrgSuggestionsFired}"
var="institution" itemValue="#{institution}" itemLabel="#{institution.granteeName}" converter="#{orgAutoCompleteConverter}"
emptyMessage="No results" multiple="true" forceSelection="true">
<p:ajax event="itemSelect" listener="#{orgView.onOrgSelect}" update="growl"/>
<p:ajax event="itemUnselect" listener="#{orgView.onOrgUnselect}" update="growl"/>
</p:autoComplete>
Example Bean
@Named
@ViewScoped
public class OrgView implements Serializable {
...
public void onOrgSelect(SelectEvent<Institution> event) {
organizations.add(event.getObject());
}
public void onInstitutionUnselect(UnselectEvent<Institution> event) {
organizations.remove(event.getObject());
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Serenity/CHANGELOG.md at master - GitHub
As Serenity.Data used 2.1.0 of Microsoft.Data.SqlClient, only sergen was affected by this issue, not StartSharp or Serene apps. Please see the linked doc, ......
Read more >Serene - Visual Studio Marketplace
Serene is a starter template to build Serenity applications. ... to reorganize existing navigation items to groups / sections (StartSharp pro theme) ...
Read more >Autocomplete plugin does not work in blueocean - Jenkins Jira
JENKINS-53637Autocomplete plugin does not work in blueocean · Bug. JENKINS-53587Sequential parallel stages show green while still running.
Read more >minQueryLength="1" and autoComplete - PrimeFaces forum
Now, I click on TireNumber, I press HOME key to position cursor at begin of field and I delete all characters with DELETE...
Read more >No way to remove google places autocomplete?
Assuming this is how things have been initialised var autocomplete = new google.maps.places.Autocomplete(input, {types: ['geocode']}); ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I updated Serenity with new material theme which one is developed from scratch. Please wait a week for release. We are working on some missing features.
According the WIKI Serenity has not been updated for PF10 yet: https://github.com/primefaces/primefaces/wiki/Updates-Of-Premium-Templates-For-PrimeFaces-X