I have multiple jPickers on same page ,how do i open single jPicker dialog at a time?

风流意气都作罢 提交于 2019-12-11 03:18:54

问题


Using multiple jPickers on same page, my problem is when i'm clicking on all three one by one it keeps open. Is there any event or method in jPicker through i can open single dialog at a time? I have checked on jPicker's site they have same problem all dialogs keeps open.

snippet of js code ,

$(function() {
  $('#id1').jPicker();
});
$(function() {
  $('#id2').jPicker();
});
$(function() {
  $('#id3').jPicker();
});

回答1:


Attach an event handler to an elem such that it closes all the open jPicker dialogs,

The logic is jPicker has containers added to the DOM in the same order as they are initialized using .jPicker() , so we close the dialogs of all other containers except the clicked container .

This seemed to be working on the demo page..

//For #id1 jPicker
  $("span.Image").click(function(){
    $('div.jPicker.Container').not(':eq('+$("span.Image").index($(this))+')').find('table input.Cancel').trigger('click');
 });

Here is the working fiddle



来源:https://stackoverflow.com/questions/23431532/i-have-multiple-jpickers-on-same-page-how-do-i-open-single-jpicker-dialog-at-a

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!