Dialog widget close problem
I am using backbone view to handle the opening and closing of the dialog widget.
I have written a function that performs a specific task when the dialog closes.
I need to stress here that inside the dialog box I have put various input elements.
Here is the function that closes the dialog box(upon clicking the cancel button) along with another action to be accomplished.
- close: function() {//this function is called when I press the cancel button
- this.$('#services').val('').trigger('chosen:updated');//this code updates the status of a jquey plugin named chosen
- this.el.dialog('close');
The above function is triggered from this code:
- render: function() {
- var buttons = {'Ok': this.save};
- if (!this.model.isNew()) {
- _.extend(buttons, {'Delete': this.destroy});
- }
- _.extend(buttons, {'Cancel': this.close});//with this code the above function is triggered
- this.el.dialog({
- modal: true,
- title: (this.model.isNew() ? 'Νew ' : 'Edit') + 'Appointment',
- buttons: buttons,
- open: this.open,
- width: 500
- });
The problem has to do with the first code segment I gave you in line 3.
The code in line 3 is effective only upon pressing the cancel button
and not when clicking the x symbol on the top right of the dialog box.
Why that happens?