局部变量key点击的时候得到不能在dialog open的时候掉用到,所以用了下面的解决办法:
后来发现也可以不用option传
$(".help").click(function() {
//Create the help dialog if needed.
var key = $(this).attr("data-help-key");
alert(key);
if ($.find("#help-dialog").length == 0){
$(document.body).append('<div id="help-dialog"><div class="dialog_content"><div class="dialog_title"><span>Yottaa Help Documentation</span>'+
'Loading Help Content...</div><div class="help_content"></div></div></div>');
$("#help-dialog").dialog({
autoOpen: false,
dialogClass: 'help_dialog',
draggable: true,
resizable: false,
height: 340,
width: 450,
open: function(event, ui) {
// Need to add the loading screen and fetch the help content async style from the server.
//Show the loading screen.
$(".help_content").html('<div style="margin:50px 185px"><img src="/images/animated/widget-loader-gray.gif" alt="Loading..."/></div>');
$.get("/helps?id="+$(this).dialog('option', 'url_key')+"&type=help", function(data) {
$(".dialog_content").html(data);
});
//TODO - Improvements cache the contents.
}
});
}
$("#help-dialog").dialog("option", 'url_key', key );
$("#help-dialog").dialog("open");
return false;
});
后来发现也可以不用option传
/*** Create and attach the help dialog.
*/
$(".help").click(function() {
if ($.find("#help-dialog").length == 0){
$(document.body).append('<div id="help-dialog"><div class="dialog_content"><div class="dialog_title"><span>Yottaa Help Documentation</span>'+
'Loading Help Content...</div><div class="help_content"></div></div></div>');
$("#help-dialog").dialog({
autoOpen: false,
dialogClass: 'help_dialog',
draggable: true,
resizable: false,
height: 340,
width: 450
});
}
//Create the help dialog if needed.
var key = $(this).attr("data-help-key");
//Add the open handler
$("#help-dialog").dialog("option", {
open: function(event, ui) {
//Need to add the loading screen and fetch the help content async style from the server.
//Show the loading screen.
$(".help_content").html('<div style="margin:50px 185px"><img src="/images/animated/widget-loader-gray.gif" alt="Loading..."/></div>');
$.get("/helps?id=" + key + "&type=help", function(data) {
$(".dialog_content").html(data);
});
//TODO - Improvements cache the contents.
}
});
$("#help-dialog").dialog("open");
return false;
});