I have this script in the tag that's making the header row in the grid frozen.
It's working good, but after I add a row to the grid with Ajax, the row goes back to regular mode, and it's not frozen anymore.
What am I missing?
<script type = "text/javascript">
$(document).ready(function () {
$('#<%=gvPayments.ClientID %>').Scrollable({
ScrollHeight: 500
});
});
</script>
Thanks.
Actually I believe the problem is $(document).ready() isn’t called after an asynchronous postback, so I suggest you have a look at this page:
http://web.archive.org/web/20101109152029/http://blog.dreamlabsolutions.com/post/2009/02/24/jQuery-document-ready-and-ASP-NET-Ajax-asynchronous-postback.aspx
Related
I am using javascript and I need to display an alert only once when the user click anywhere in the site. But make sure it will not pop up everytime the user click anywhere.
Im not professional but I need this code to embed in my e-commerce site. I have tried a regular onload alert. but it will show once the page is loaded. then i tried this automatic code:
</html>
<head>
<script language="JavaScript">
<!--
document.onclick = myClickHandler;
function myClickHandler() {
alert("All orders require minimum two weeks notice due to the nature of event and wedding products");
}
-->
</script>
</head>
<body>
</html>
and works, but every time I click appear and that is annoying. I need a onclick event, anywhere in the page... to display an alert only once. to advise the user about important info.
Desperatly need some solution. Thanks
$(function () {
$(document).on('click.once', function () {
alert("Alerted once");
$(document).off('click.once');
})
});
This makes use of the .off() and named event feature in jQuery.
.off feature
event namespaces
My project is master/content. The client validation always scrolls the first control that is not valid to the top of the page (0, 0). I am trying to override the default window.scrollTo by putting following client-side script in the content page, but it doesn't seem working. Can anyone tell me what is wrong? I tried put this in the master page, not working either.
<script type="text/javascript">
window.scrollTo = function() { }
</script>
You need to disable FocusOnError Property
Using jQuery 1.4.2 from Google hosted Code.
Is there a reason why the following javascript does not fire all 3 document.ready functions when the document is ready?
The first $(document).ready() function, which renders headers, and the second, which gives a 'Foo' alert box triggered, but subsequent ones in new <script> blocks aren't triggered,
<script type="text/javascript">
$(document).ready(function () {
Cufon.replace('h1'); // Works without a selector engine
Cufon.replace('h2'); // Works without a selector engine
Cufon.replace('h3'); // Works without a selector engine
Cufon.now();
});
$(document).ready(function () { alert("Number Foo"); });
</script>
// html tags
<script type="text/javascript">
$(document).ready(function () { alert("Number One"); });
$(document).ready(function () { alert("Number Two"); });
</script>
These are in seperate web parts, hosted on the same page in Sharepoint2010
I can think of three forensic things to try, right off:
try it with non-google-hosted
libraries.
comment out the Cufon
calls -- I believe Cufon does some
crazy stuff to download additional
resources, yes? That may be
interfering.
sub in
$(window).load() for one or more
of your $(document).ready()
callback defs. They have different
firing criteria --
$(window).load() waits for
everything to load up, allegedly --
but the substitution may be
revealing.
Of course, console.log() and alert() will be your in-leu-of-debugger-breakpoint best friends in this case.
you're missing a closing curly bracket and parenthesis in the second script tag
You are missing a }); in the end of the last $(document).ready
Once you correct this it should work
EDIT:
Since you say now that each script tag is in a separate web part I believe the problem itself is not in the scripts. Something else in your page is messing up your code.
I have an ASP.NET reportviewer in a page whose width (a div width) I am trying to determine.
I have the test code below. The first alert returns the proper client id. I can see the div in the html source. I can see its width in FireBug. However the second alert returns null. The syntax looks fine. Why is it returning null?
<script type="text/javascript" src="includes/jquery-1.4.2.min.js"></script>
<script type="text/javascript" language="javascript">
alert('<%=rvMain.ClientID %>');
alert( $('#<%=rvMain.ClientID %>').width() );
</script>
Have your elements loaded at the time that javascript fires? Try using a document.ready
call and see if you get the same result.
Are you wrapping that code in $(document).ready(function () { /* code */ });? If not, you may be trying to reference an element that doesn't yet exist in the DOM.
However the answers above are correct but if you are not using jquery then you can use a trick which is to do the javascript calling at the end of the document.
this happens because the order in which the files are received from server are different and javascript execution happens as soon as it loads
I have a usercontrol with a couple of drop downs Lists and a button, I want the user to click the button (Which response.redirects depending on the selection in the DDL's).
Now instead of redirecting straight away, I want to display a little loading icon for 3 seconds and then redirect... Has anyone done anything like this?
An artificial delay where none is needed is kinda lame. What you can do instead is on submission of your form display your throbber. I use the following on a document upload form where large media files are being posted.
<script type="text/javascript" id="PreJavaScript">
function NUsubmit(){
document.getElementById("uploadFormInputs").style.display = 'none';
document.getElementById("progressBar").style.display = 'block';
return true;
};
function init() { document.getElementById("UploadFormObject").onsubmit = NUsubmit; };
window.onload = init;
</script>
If I remember correctly, in some versions of IE the animated gif didn't play but it worked fine in IE6+ and FireFox.
This way if the postback is quick they never see the throbber but if it takes a while they see it and it gives them the sense that something is happening.
You can perform delays with the setTimeout() function in javascript.
setTimeout(function() { alert('After 5 seconds.'); }, 5000);
You're probably going to need to override a couple things in your Javascript and use a "setTimeout" to delay the loading.
<script type="text/javascript" >
var __handleSubmit = theForm.submit;
theForm.onsubmit = function() {
alert('loading'); //Show your message here
window.setTimeout(function() {
__handleSubmit();
}, 3000);
}
</script>
You might want to play with a bit more... this is may not work for all instances since I've never done it.
If the delay is simply for "aesthetics", to make it appear it is working, then I'd recommend against it - programmers appear to be the only people that think loading bars are cool :)
Looks like you should implement this page using AJAX. You can place a progress indictor on your page to alert the user that a long running process is taking place.
I got this working by using
System.Threading.Thread.Sleep(4000);
In the postback