div class="list-show" data-action="option-tray">--> when clicked on dropdown box it should add display as block but it is always adding hidden in firefox. But it is working fine in chrome. I think there is some problem with " $(window).click(function(e) { base.$optionTray.hide(); });" code. I am not able to resolve it.
//This is the Typescript file which is compiled to javascript
private rootSelectionString: string = ".js-multiselectDropdown";
private actionButtonSelectionString: string = "*[data-action='colex']";
private optionTraySelectionString: string = "*[data-action='option-tray']";
private checkboxTraySelectionString: string = "*[data-action='checkbox-tray']";
private selectedClass= "selected";
private $rootElement: JQuery;
private $optionTray: JQuery;
private $checkboxTray: JQuery;
private $actionButton: JQuery;
private dataId;
private listLength;
private searchCheckedBoxes;
private checkBoxes;
constructor(el) {
var base = this;
base.$rootElement = $(el);
base.$optionTray = base.$rootElement.find(base.optionTraySelectionString).eq(0);
base.$checkboxTray = base.$rootElement.find(base.checkboxTraySelectionString).eq(0);
base.$actionButton = base.$rootElement.find(base.actionButtonSelectionString).eq(0);
base.optionPopulation();
base.attachEvent();
base.initialValueCapture();
}
private attachEvent() {
var base = this;
if(base.$rootElement.length!==0) {
base.$optionTray.hide();
base.$actionButton.click(function(){
event.stopPropagation();
base.$optionTray.toggle();
});
$(window).click(function(e) {
base.$optionTray.hide();
});
$(".list-show").click(function(event) {
event.stopPropagation();
});
base.$optionTray.find('li[data-id]').click(function() {
base.$actionButton.find('span').html("");
$(this).toggleClass(base.selectedClass);
if($(this).hasClass(base.selectedClass)){
base.$checkboxTray.find('[data-id="'+$(this).data('id')+'"]').attr('checked','1');
}
else {
base.$checkboxTray.find('[data-id="'+$(this).data('id')+'"]').removeAttr('checked');
}
base.searchCheckedBoxes = base.$rootElement.find('input:checked').map(function() {
return $(this).val();
});
var dataArr=[];
$.each(base.searchCheckedBoxes.get(),function(i,v) {
dataArr.push(v);
});
if(dataArr.length!==0) {
base.$actionButton.find('span').append(dataArr+",");
}
else {
base.$actionButton.find('span').html("Choose Tag");
}
});
}
}
//Here is the HTML code where the dropdown menu is displayed
<div class="js-multiselectDropdown" style="float:left">
<div class="action-btn " data-action="colex"><span>Choose Tag</span></div>
<div class="list-show" data-action="option-tray">
<ul></ul>
</div>
<div data-action="checkbox-tray" class="hidden">
<input type="checkbox" value="O"/>O</br>
<input type="checkbox" value="G" checked/>G</br>
<input type="checkbox" value="E"/>E</br>
<input type="checkbox" value="N" checked/>N</br>
</div>
</div>
It appears, that the below function is not passing through the event property
base.$actionButton.click(function(){
event.stopPropagation();
base.$optionTray.toggle();
});
Doesn't appear to take event in on the function(), I don't have a TypeScript compiler setup, but if you just add event into the function() definition, you should be good to go.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.