By select, I mean select()
My code is this:
$('.show-embed-link').unbind('click');
$(".show-embed-link").click(function(e){
var id = $(this).attr("rel");
e.preventDefault();
showEmbed(id);
setTimeout(function() {
$("#general_message").focus();
}, 100);
});
.show-embed-link
is not dynamic element. It is a <a>
element.
showEmbed
will generate a dynamic element.
function showEmbed(id) {
var message = '<iframe width="1000" height="800" src="//storyzer.com/stories/'+id+'" frameborder="0" allowfullscreen></iframe>';
message = HtmlEncode(message);
showOverlayForGeneral(message, "Embed work", {'spinner': false, 'extraheight': 90, 'showclose': true});
}
showOverlayForGeneral
is responsible for generating the dynamic element with the message.
function showOverlayForGeneral(message, title, options) {
options = (typeof options === "undefined") ? {} : options;
var defaultOptions = {
"message": "",
"extraheight": 150,
"spinner": true,
"showclose": false
};
// code removed because not relevant to this situation...
$('#general_message').unbind('focus');
$('#general_message').focus(function () {
$('#general_message').select().mouseup(function (e) {
e.preventDefault();
$(this).unbind("mouseup");
});
});
}
The focus
code is taken from https://stackoverflow.com/a/3380493
Currently, my div html is not selected. How can I tell if the select event is happening?