September 2009 Entries

How to stop and prompt user when closing browser

Scenario: For some reason you want to stop the user from closing the browser window or from redirecting away from the current page, based on some condition. The solution: window.onbeforeunload = function(event) { return true; } This will prompt you for input (like the JavaScript confirm pop-up menu). There is no way to override the text though. Some concerns: This works great but it may not be what you want all the time, as no matter if you click a hyperlink, hit submit, etc will prompt the user, ......

jQuery disable button intercepts Request Object

Scenario: Hijack all my save buttons via the script below to override the value, from Save to Saving...., and then also disabling the button so they cannot hit it 1000 times. $(document).ready(function() { form.find(':submit').each(f... { $(this).attr("disabled", "disabled").val("Saving...."); }); }); The Issue: I have several submit type buttons on the page, like Save, Sand and Proceed, Delete, etc, so I use the Request.Form object to see what button was pressed to decide what to do. Well, ......

Why does F10 (continue) in Visual Studio not work?

Scenario: I'm debugging a (web) project in Visual Studio 2008. It is breaking and the first break point only, and thereafter when i hit F10 it ignores and subsequent break points and runs all the way through. Why is this happening? Couple of pointers before we discuss the solution I have tried 'clean solution'. Other breakpoints sometimes(!) skipped, even in the same method Make sure that you're in Debug mode not in Release. There could be an exception while executing the instruction in question. ......

Intercept a form submit with jQuery and prevent or allow submission

Goal: Intercept a form submit, find out what submit button was clicked/invoked and decide to prevent the submission or continue to submit. Solution: $(document).ready(function() { $("form").submit(function(e) { if (e.originalEvent.explicitOr... == "myButton") { if (some status is true continue to submit the form) return true; //If the status above is false continue to prompt the user if they want to submit or not var ok = confirm('Do you really want to save your data?'); if (ok) { return ......

Prevent repeated clicks on submit button

Scenario: The user wants to save something and hits the Save button (type=submit). The event performs an Ajax call to send the request to the server. The user, being unaware or not sure if their request is being processed or if they clicked the Save button properly, click it again, and again, causing several Ajax requests, which could be a real problem, if the update is to, for example, transfer funds to your ex-girlfriend's account The solution: Prevent the user from being able to click the Save ......

jQuery AutoComplete in ASP.NET MVC Framework

Goal: jQuery AutoComplete in ASP.NET MVC Framework with callback to customize result Platform/Environment: Asp.Net Mvc version 1 jQuery 1.3.2 Autocomplete - jQuery plugin 1.0.2 Quick Solution: Here I am simply returning a list of account names: $('#Name').autocomplete( $('#ajaxListMatchingAccount... { delay: 10, minChars: 3, matchSubset: 1, matchContains: 1, cacheLength: 10, autoFill: true, mustMatch: false, selectFirst: true, max: 15 } ); ajaxListMatchingAccountName... - this is a ......

Browser engine performance related to JavaScript

Normal 0 false false false MicrosoftInternetExplorer4 st1\:*{behavior:url(#ieooui) } /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.000... mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} ......

jqGrid hide columns but show when editing/adding

Issue: I have a grid which I have what I can only describe as containing “Core” data and “Minor” data. What I'd like to be able to do is to show the Core data in the main grid view but to allow the user to add/edit/view the Core and Minor data when they open the relevant dialog. In essence this would be like having hidden columns that were viewable/editable when the dialogs were opened with form editing/viewing. The Minor data is only of interest to some users, so I don't want to show it in the main ......