How to use create event on a jQuery dialog in following scenario?

PHPLover

I've have following dialog pop-up HTML which is hidden initially when page loads(look line style="display:none;" in div):

<div id="searchPopContent" class="c-popup" style="display:none;">
      <div id="pop-up">
      <div class="error_msg" id="report_error" style="text-align:center; margin-top:5px;">

        </div>
        <div class="clear"></div>
        <form name="question_issue_form" id="question_issue_form" class="login_box" method="post" action="question_issue.php">
          <input type="hidden" name="form_submitted" id="form_submitted" value="yes"/>
          <input type="hidden" name="post_url" id="post_url" value="question_issue.php"/>
          <input type="hidden" name="op" id="op" value="question_issue"/>
          <input type="hidden" name="question_id" id="question_id"/>

          <table class="trnsction_details" width="100%" cellpadding="5">
            <tbody>    
              <tr>
                <td></td>
                <td>
                  <input type="checkbox" name = "que_issue[]" value = "Question is wrong" id ="chkQueWrong">Question is wrong</input>
                </td>
              </tr>
              <tr>
                <td></td>
                <td><input type="checkbox" name = "que_issue[]" value = "Answers are wrong" id ="chkAnsWrong">Answers are wrong</input></td> 
              </tr>
              <tr>
                <td></td>
                <td><input type="checkbox" name = "que_issue[]" value = "Question direction is incorrect" id ="chkDirIncorrect">Question direction is incorrecct</input></td>             
              </tr>
              <tr>
                <td></td>
                <td><input type="checkbox" name = "que_issue[]" value = "Other" id ="chkOther">Other</input></td>          
              </tr>
              <tr>
                <td></td>
                <td class="set_message" style="display:none;"><textarea name="que_issue_comment" id = "que_issue_comment" rows="4" cols="25" maxlength="100"></textarea></td>      
              </tr>
              <tr>
                <td></td>
                <td><input type="submit" name="submit" value="Submit" class="report_question_issue" class="buttonin"/></td>
              </tr>
            </tbody>
          </table>
        </form>
      </div>
    </div>

I want to dynamically set the value of input type hidden having id="question_id". After doing so much research I came to know that I have to use create() method of jQUery UI dialog plugin to set the hidden field value in UI dialog dynamically. I tried to call create() event in jquery dialog call but couldn't be able to set the value. Can anyone please help me in this regard please? Following is the code I tried to use create() event.

$(document).on("click","a[class='que_issue']", function (e) {
var hypertext = this.innerHTML;
  var que_id = hypertext.substring(3);

  //document.getElementById("question_id").value = que_id;
  //$("#question_id").val(str);

    var data = $('#searchPopContent').html();

    var title = "Question issue";
    var dialog_title   = title; 
    var dialog_message = data; 
            var $dialog = $("<div class='view_result'></div>")
     .html(dialog_message)
     .dialog({
           autoOpen: false,
           modal:true,
           title: dialog_title,
           width: 400,                     
           close:{
           },
           create: function() {
       $("#question_id").val(que_id);
    }
     });
     $dialog.dialog('open');

    return false;
});

Also there is no errror in the firebug console for above code.

Dio Phung

I modified your JS: http://jsfiddle.net/JyPLc/1/ , it works.

$(document).ready(function(){    
    $("#searchPopContent").dialog({
       autoOpen: false,
       modal:true,
       title: "Question issue",
       width: 400, 
       close:{
       }   
     });
});

$("a.que_issue").on("click", function (e) {
    var hypertext = this.innerHTML;
    var que_id = hypertext.substring(3);
    var title = "Question issue";

    $("#question_id").val(que_id);
    $("#qns_id").val(que_id); //this is just to show it works, can delete it
    $("#searchPopContent").dialog('open');

    return false;
});

You should modify the HTML first, then just call the dialog() to show to popup.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to implement autocomplete functionality using PHP, jQuery and AJAX in following scenario?

From Dev

WHy the call is not going to the jQuery function in following scenario?

From Dev

How to create an inner array inside parent array in following scenario?

From Dev

How to manipulate the array in following scenario?

From Dev

How to use threading or Task pattern in following scenario

From Dev

How to change the array in following scenario?

From Dev

How to get result in following scenario

From Dev

How to use create Jquery Confirm Dialog before switching tabs

From Dev

What pattern to use for the following scenario?

From Dev

How would I improve the performance in the following scenario

From Dev

How to use expandable list view in the following scenario

From Dev

How to create a fixed dialog box with jQuery?

From Dev

How to use RethinkDB indices in the following scenario?

From Dev

How to show the groupwise result for the following scenario?

From Dev

How to call a jQuery function on click event in the following scenario?

From Dev

How to make the checkbox working properly in following scenario?

From Dev

How to access outer div element in jQuery following scenario?

From Dev

How to append data to a particular div in jQuery in the following scenario?

From Dev

how to make a left outer join in following scenario

From Dev

How to use threading or Task pattern in following scenario

From Dev

How to show/hide the content of a table in following scenario using jQuery?

From Dev

How to create a dialog box that appears without any event triggered in jQuery?

From Dev

How to get result in following scenario

From Dev

How to access json data and use in if condition in following scenario?

From Dev

What pattern to use for the following scenario?

From Dev

How to avoid duplicates in following SQL scenario

From Dev

How to apply conditional aggregation in SQL the following scenario?

From Dev

How can I use list comprehension in following scenario?

From Dev

How to deal with following scenario in QTP?

Related Related

  1. 1

    How to implement autocomplete functionality using PHP, jQuery and AJAX in following scenario?

  2. 2

    WHy the call is not going to the jQuery function in following scenario?

  3. 3

    How to create an inner array inside parent array in following scenario?

  4. 4

    How to manipulate the array in following scenario?

  5. 5

    How to use threading or Task pattern in following scenario

  6. 6

    How to change the array in following scenario?

  7. 7

    How to get result in following scenario

  8. 8

    How to use create Jquery Confirm Dialog before switching tabs

  9. 9

    What pattern to use for the following scenario?

  10. 10

    How would I improve the performance in the following scenario

  11. 11

    How to use expandable list view in the following scenario

  12. 12

    How to create a fixed dialog box with jQuery?

  13. 13

    How to use RethinkDB indices in the following scenario?

  14. 14

    How to show the groupwise result for the following scenario?

  15. 15

    How to call a jQuery function on click event in the following scenario?

  16. 16

    How to make the checkbox working properly in following scenario?

  17. 17

    How to access outer div element in jQuery following scenario?

  18. 18

    How to append data to a particular div in jQuery in the following scenario?

  19. 19

    how to make a left outer join in following scenario

  20. 20

    How to use threading or Task pattern in following scenario

  21. 21

    How to show/hide the content of a table in following scenario using jQuery?

  22. 22

    How to create a dialog box that appears without any event triggered in jQuery?

  23. 23

    How to get result in following scenario

  24. 24

    How to access json data and use in if condition in following scenario?

  25. 25

    What pattern to use for the following scenario?

  26. 26

    How to avoid duplicates in following SQL scenario

  27. 27

    How to apply conditional aggregation in SQL the following scenario?

  28. 28

    How can I use list comprehension in following scenario?

  29. 29

    How to deal with following scenario in QTP?

HotTag

Archive