Saturday, November 28, 2009

[jQuery] jqDialog within document.ready

I have an ASP.Net form that posts data back to a button with codebhind
that sets a hidden label based on the status of the data posted. When
the page posts back, I want to display a "notify" message using
jqDialog. Here is the code I am using:

$(document).ready(function() {
var testString = $('#lblStatus').text();
alert('3' + testString);
if (testString.indexOf('Save') >= 0) {
alert('6' + testString);
var userName = $('#comboExistingUsers').val();
alert(userName);
jqDialog.notify("<BR /><BR />Saving " + userName + "'s
data.", 3);
}

The alerts show that I am getting as far as the jqDialog call but the
notify is not showing up.

I have used this code on the same form from within a button as
follows:

// notify saving data
// $('#btnSave').click(function() {
// var userName = $
('#comboExistingUsers').val();
// jqDialog.notify("<BR /><BR />Saving " +
userName + "'s data.", 3);
// setTimeout('__doPostBack(\'btnSave\',
\'\')', 0);
// return false;
// });

So I have the syntax correct. Is there a reason that calling notify
from the document.ready function would not work? If so, when should I
call it?

TIA,
John

No comments: