problem using confirm dialog
I have in my page a button that onclick opens a dialog (add-to-blacklist_dialog).
In this dialog, the user has a textbox to enter some text and then hits "Ok"
on the Ok click, a second dialog (confirm_word_add_dialog) opens to confirm what the user entred.
The problem is when the user hits "cancel" and returns to the first dialog and changes the text the hits "Ok" of the first dialog,
the "new text" entred is not taken into consideration and i still have the old text.
Any Ideas?? thanks in advance
Here isa snippet of my html code
- <button id="add-word"
- class="ui-button ui-state-default ui-corner-all">add a word
- </button>
-
- <div id="add-to-blacklist_dialog"
- title="Add a word to list">
-
-
- <form>
- <fieldset><label for="word">Word to add</label> <input
- type="text" name="word" id="word"
- class="text ui-widget-content ui-corner-all" /></fieldset>
- </form>
- </div>
-
- <div id="confirm_word_add_dialog"
- title="Confirm Adding word?">
- <
- class="ui-icon ui-icon-alert"
- style="float: left; margin: 0 7px 20px 0;"></span>Would you really want
- to add <a class="replacement"></a> to the list of blacklisted words ?<br
- style="height: 40px">
- All documents conatning the word <a class="replacement"></a> will be deleted</p>
- </div>
and a snippet of my function
- $( function() {
- var word = $("#word");
- //some code
- $("#add-to-blacklist_dialog")
- .dialog(
- {
- bgiframe : true,
- autoOpen : false,
- height : 220,
- modal : true,
- resizable : false,
- buttons : {
- 'Ok' : function() {
- var bValid = true;
- allFields.removeClass('ui-state-error');
-
- $('.replacement').replaceWith('<span style=" font-weight: bold;color: red;">' + word.attr("value") + '</span>');
- $('#confirm_word_add_dialog').dialog('open');
- return false;
- $(this).dialog('close');
-
- },
- Cancel : function() {
- $(this).dialog('close');
- }
- },
- close : function() {
- allFields.val('').removeClass('ui-state-error');
- }
- });
- $("#confirm_word_blacklist_dialog").dialog( {
- bgiframe : true,
- autoOpen : false,
- height : 200,
- width : 400,
- resizable : false,
- modal : true,
- buttons : {
- Cancel : function() {
- $(this).dialog('close');
- word.text(' ');
- },
- 'Ok' : function() {
-
- //some treatment
- });
- $(this).dialog('close');
- $("#add-to-blacklist_dialog").dialog('close');
- return false;
- }
- },
- close : function() {
-
- }
- });
-
- });