www.webdeveloper.com
Results 1 to 4 of 4

Thread: Using the the return event in a jQuery dialog

Hybrid View

  1. #1
    Join Date
    Jan 2013
    Posts
    2

    Using the the return event in a jQuery dialog

    The return event from the jQuery in IE works and returns text (event.target.innerText) that was typed in by the user. I need this to work in all browsers...of course Can someone show me how to get this to work in all browsers, so I know what the user typed in and can save it. I'm using ASP.Net and trying to save the information server side is the reason I put the returned text into a hiddenBasicInformationComments textbox (which is set to run at server). If anyone sees a better way to do what I want, please don't hesitate to let me know.

    Code:
          
    $("#divbasicInformationComments").dialog({
                 autoOpen: false,
                 show: "blind",
                 width: 500,
                 height: 480,
                 draggable: false,
                 position: 'center',
                 modal: true,
                 close: function (event, ui) {
                     $(".hiddenBasicInformationComments").val(event.target.innerText);  //event.target.innerText returns null for Firefox
                 },
                 open: function (type, data) {
                     $(this).parent().appendTo("form:first");
                 }
             });

  2. #2
    Join Date
    Nov 2010
    Posts
    1,082
    as you have noticed innerText is IE only. And IE doesn't recognize what others do, textContent. you could check, something like
    Code:
    var txt= event.target.innerText||event.target.textContent
    $(".hiddenBasicInformationComments").val(txt)
    or if you are already using jQuery, you might be able to get away with
    Code:
    $(".hiddenBasicInformationComments").val(event.target.text())
    none of that is tested, but something like that will work. jQuery is designed to eliminate cross browser drama, so if you are already using it you should try to stick to it, then you won't have these troubles

  3. #3
    Join Date
    Jan 2013
    Posts
    2

    First Solution Works

    Quote Originally Posted by xelawho View Post
    as you have noticed innerText is IE only. And IE doesn't recognize what others do, textContent. you could check, something like
    Code:
    var txt= event.target.innerText||event.target.textContent
    $(".hiddenBasicInformationComments").val(txt)
    or if you are already using jQuery, you might be able to get away with
    Code:
    $(".hiddenBasicInformationComments").val(event.target.text())
    none of that is tested, but something like that will work. jQuery is designed to eliminate cross browser drama, so if you are already using it you should try to stick to it, then you won't have these troubles
    Thanks for the help...the first solution you proposed works for me

  4. #4
    Join Date
    Jan 2013
    Posts
    1
    Hi all, This forums might be my source of information. Please allow me to join in this forums, and hope you can welcome me you all. thank you...


    **Links removed by Site Administrator so it doesn't look like you're spamming us. Please don't post them again.**

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles