0

I' trying to implement Bootstrap confirmation

on top of FullCalendar

the code posted below works for basically everything

except when I set "singleton" to "true"

<script src="~/Scripts/jquery-3.3.1.slim.min.js"></script>
<script src="~/Scripts/jquery-3.3.1.min.js"></script>
<script src="~/Scripts/umd/popper.js"></script>
<script src="~/Scripts/umd/popper.min.js"></script>
<script src="~/Scripts/jquery-ui.min.js"></script>
<script src="~/Scripts/bootstrap.bundle.js"></script>
<script src="~/Scripts/bootstrap-confirmation.js"></script>
<script src="~/Scripts/moment-with-locales.min.js"></script>
<script src="~/Scripts/fullcalendar/fullcalendar.min.js"></script>
<script src="~/Scripts/fullcalendar/locale-all.js"></script>
<script src="~/Scripts/jquery.signalR-2.4.0.min.js"></script>
<script src="/signalr/hubs"></script>
<script type="text/javascript">


$(function () {
            hub = $.connection.planningHub;
            hub.client.update = function (v, s, e, is, ie) {
                fc.fullCalendar('refetchEvents');
            };
            $.connection.hub.start().done(function () {
                fc = $('#calendar').fullCalendar({
                    defaultView: 'agendaWeek',
                    header: {
                      ...
                    },
´
                    events: {
                      ...
                            };
                        }
                    },

                    eventClick: function (calEvent, jsEvent, view) {
                        jsEvent.preventDefault();
                        var fcId = calEvent.id;
                        var eventTarget = jsEvent.target;

                        $(eventTarget).confirmation({
// MAYBE HERE!

                            rootSelector: eventTarget,
// MAYBE HERE!

                            placement: 'left',
                            title: 'do you want to delete?',

// HERE!
                            singleton: true,
// HERE!
                            popout: false,
                            onConfirm: function () {
                                $.post('@Url.Action("DeletePlanning")', { id: fcId}, function (r) {
                                    switch ( r.status) {
                                        case 'success':
                                            fc.fullCalendar('refetchEvents');
                                            break;
                                        case 'error':
                                            console.error(r.message);
                                            rv();
                                            break;
                                     }
                                   }
                                );
                            },
                            oncancel: function () { },
                        });
                        $(eventTarget).confirmation('show');
                    }
                });
            });
        });

at that point it keep creating multiple popover,

with the difference that they close all at once when one closes.

Any Idea?

I really need it to be singleton!

(be forgiving, I'm really new in js and asp.net)

thanks in advance for the help

Francesco Iapicca
  • 2,618
  • 5
  • 40
  • 85
  • why do you need it to be singleton, exactly? – ADyson May 23 '19 at 13:58
  • It's kind of odd, what you describe, since the idea of the singleton option is to prevent more than one confirmation box from appearing at one time. – ADyson May 23 '19 at 14:02
  • there's an interaction with a db and i'd like that no new pop up opens until the interaction is over, so I guess singleton is the best option – Francesco Iapicca May 23 '19 at 14:15
  • Why would it matter? I can see, all you're doing is deleting an event. If you delete more than one event at once, so what? What problem does that cause? – ADyson May 23 '19 at 14:19
  • you have to consider the usability, plus more people deleting the same thing through signalR and so on, I don't want to be rude, but my question was not "do I need it to be singleton", if can want to help with my problem I thank you for that, otherwise we can probably use our time in a more productive way – Francesco Iapicca May 23 '19 at 14:25
  • "more people deleting the same thing" ...having a singleton confirmation won't stop that from happening, because those other people are using a different browser. And if the same user deletes the same thing well, ok it's a waste of a request but a) most people are paying more attention than that, and b) your server can presumably just ignore the request. – ADyson May 23 '19 at 14:36
  • I realise whether to use singleton isn't your question, but I'm thinking you've got an odd-sounding bug (sounds like it does the opposite of what's intended), and you've already mentioned that the code works fine when you don't add that option, so I'm wondering if actually the most productive use of time would be to forget about chasing this strange little bug and get on with making more features. That's just my opinion of course. – ADyson May 23 '19 at 14:37
  • 1
    P.S. One thing I notice immediately as being odd about your code is that you've included `jQuery` twice (both the slim version and the full version). That can occasionally cause weird problems. Since you're using ajax, you'll need the full version, so try removing the slim version and see if that resolves anything. You've also included `popper` twice (minified version and original version), so again please remove the duplicate and see if it helps. – ADyson May 23 '19 at 14:39
  • thanks for the hint, I used both because slim is required by "confirmation" and the doc for "full calendar" uses the full version, I'll try to use only slim (I've already tried only with full and doesn't work) – Francesco Iapicca May 24 '19 at 08:56
  • That makes no sense. You need the full version of jQuery to use the AJAX functions like $.post etc, since they are not included with the slim version. The slim version is just a cut-down version of the full version. Some things are removed, but it contains nothing extra which is not in the full version. So if your confirmation code works with slim it should work with full. Where it might have a problem is when you include both at once. And don't forget to remove the duplicate popper file as well. – ADyson May 24 '19 at 08:57

0 Answers0