2

I wonder, if there is a proper way to remove the default close button in the title bar and change it with other, to which I want to assign other function than Close. I manage to change the classes, but despite that, the close function seems to override to any in the titlebar.

My current code for changing classes:

var closeButton = $("#dialog").parent().find('.ui-dialog-titlebar a');
closeButton.attr("class","ui-dialog-titlebar-lock");
closeButton.find("span").attr("class","ui-icon ui-icon-lock");

The HTML code of the titlebar:

<div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" unselectable="on" style="-moz-user-select: none;">
  <span id="ui-dialog-title-profile-dialog" class="ui-dialog-title" unselectable="on" style="-moz-user-select: none;">Edit My Profile</span>
    <a class="ui-dialog-titlebar-close ui-corner-all" href="#" role="button" unselectable="on" style="-moz-user-select: none;">
      <span class="ui-icon ui-icon-closethick" unselectable="on" style="-moz-user-select: none;">close</span>
    </a>
 </div>

As a result of previous javascript code, the classes are overriden, but the function remains. This is because of jQuery inner code, I suppose, isn't it? Any advices how to overcome it easily?

2 Answers 2

1

I assume you mean the close function remains.

What you can do is to persist the old click event, then unbind it, add your own which internally calls the old click to actually close the dialog.

//persist old click
var oldClickFn = closeButton.click;

closeButton.unbind('click').click( function(){
    //functionality you want

    //call the persisted click
    oldClickFn && oldClickFn()
});
Sign up to request clarification or add additional context in comments.

Comments

0

The following should work:

var dialog = // here open the dialog and assign it to the dialog variable
dialog.parent(".ui-dialog").find(".ui-dialog-titlebar-close").unbind('click');        
dialog.parent(".ui-dialog").find(".ui-dialog-titlebar-close").show();   
dialog.parent(".ui-dialog").find(".ui-dialog-titlebar-close").bind('click', function() { showNoteDialogClose(null, null) });  


function showNoteDialogClose(data, args)
{
 /////////
}   

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.