Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a popup where you can add an event, so if you click on a event you see the details of the event.And I have a delete button , like this

I have this:

C#
eventClick: function (calEvent, jsEvent, view) {
                   alert(calEvent.id)


Then I can see the id. But I also have a delete function, like this:

C#
$('#btnPopupDelete').click(function (e, calEvent) {

           var id = calEvent.id;
           alert(id);

           DeleteEvent(id)
           //$('#popupEventForm').hide();
       });


but then id is undefined. but this is working: var id = 32

I solved like this:
C#
eventClick: function (calEvent, jsEvent, view) {



                   $('#btnPopupDelete').click(function () {


                       var id = calEvent.id;
                       alert(id);

                       DeleteEvent(id)
                       $('#popupEventForm').hide();


                   });


only it has to be refreshed, otherwise after delete the event is still staying, but f5 and the event is gone




Thank you
Posted
Updated 29-Jan-15 4:45am
v5
Comments
ZurdoDev 29-Jan-15 9:35am    
calEvent is not something built-in to JS which means it isn't available on a button being clicked.
[no name] 29-Jan-15 9:37am    
Oke, but how to reach the id then? Because if I do, like this: var id = 22; it works. but this is ofcourse hardcoded. how to call the id of the calEvent?

As RyanDev has already mentioned calEvent is not a built-in function, and that is why you just cannot call the id member, because it is undefined.

What you might try to do is, to check for which event was clicked. You can make a good use of the this keyword in jQuery to run the code over the object that raised the event. Think of your code like this,

JavaScript
$('#btnPopupDelete').click(function () {
   // Get the id attribute; you can use other attributes too
   var id = $(this).attr('id');
   // alert(id);
 
   DeleteEvent(id);
   //$('#popupEventForm').hide();
});


Now, suppose if the ID of your button was the ID of the event to be deleted, then this code would pass the value of the ID attribute of the button and the event would be deleted.
 
Share this answer
 
Comments
[no name] 29-Jan-15 10:22am    
Thank you for your answare. ok, but how to get the id of the event, it is like: calEvent.id. I get now the id of button. this is what it has to do: id= calEvent.id;but how to call the calEvent?
Afzaal Ahmad Zeeshan 29-Jan-15 10:30am    
As already said there is no calEvent object in JavaScript, and I am unaware of it. I agree you can call the member (id) of the object calEvent just like calEvent.id. But JavaScript - as well as me - is unaware of this object. So, either please elaborate that object, where it is how you created it. Or you can use this code and next time add the event's ID inside the button's ID.
eventClick: function (calEvent, jsEvent, view) {



$('#btnPopupDelete').click(function () {


var id = calEvent.id;
alert(id);

DeleteEvent(id)
$('#popupEventForm').hide();


});
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900