/    Sign up×
Community /Pin to ProfileBookmark

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”);
}
});
[/CODE]

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@xelawhoJan 08.2013 — 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)[/CODE]


or if you are already using jQuery, you might be able to get away with
[CODE]$(".hiddenBasicInformationComments").val(event.target.text())[/CODE]

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
Copy linkTweet thisAlerts:
@AlfredAStant13Jan 08.2013 — 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.**
Copy linkTweet thisAlerts:
@wannabe67authorJan 10.2013 — 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)[/CODE]


or if you are already using jQuery, you might be able to get away with
[CODE]$(".hiddenBasicInformationComments").val(event.target.text())[/CODE]

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[/QUOTE]


Thanks for the help...the first solution you proposed works for me
×

Success!

Help @wannabe67 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...