Showing posts with label jQuery. Show all posts
Showing posts with label jQuery. Show all posts

Friday, 11 May 2012

jQuery how to FadeOut() then Remove()

How to stop click events firing on child divs

If you have multiple divs stacked on top of each other, and all divs are selectable (ui-selectable) you can stop the click events bubbling down to the lower level by adding event.stopPropagation() to the click event of the top most div. eg:

Wednesday, 25 April 2012

jqGrid Ensure last edited cell is saved when save button clicked

I had a jqGRid that is shown in a jQuery dialog. The dialog has a save and cancel button. A problem occured where the last column in the grid was edited, but as the user did not press enter to commit the cell value, the last value entered in the grid was not saved when the 'Save' button was clicked. To get around this, I saved the current row and column indexes in the afterEditCell Method, then called my custom save cell method (saveCurrentCell) when the OK button is clicked on the jQuery dialog. This ensures that the last cell being edited is saved before the dialog is closed. Markup: Javascript:

Thursday, 12 January 2012

Restoring focus to a control after an UpdatePanel Update

Using Ajax update panels can sometimes cause issues with restoring the focus of the control after the update panel updates.

This can be achieved with a little jQuery and hooking the begin and end request events of the PageRequestManager.

Tuesday, 10 January 2012

How to have an editable checkbox column in a jqGrid

If you need to have clickable checkboxes in a jqgrid that update immediately then this is the code for you. It took me about a day and a half to get this worked out!




aspx:

Javascript:
cs:

Friday, 16 December 2011

How to load a drop down in a jqGRid with inline editing

Javascript:


aspx:

cs:

Wednesday, 14 December 2011

How to Show a jQuery Dialog from Code behind

If you need to show a jQuery dialog from codebehind you can do so with the following code:

aspx:



js in aspx:

Note: dlg.parent().appendTo(jQuery('form:first')) is required so the dialog can be the same state after postback



code behind:

Basically we are adding a script to page load to create the dialog by calling our javascript method.

Friday, 2 December 2011

Showing a modal dialog while page is updating

If you want to show a modal dialog while an update panel is updating it can be achieved with the following code:

Markup:


Javascript

Monday, 7 November 2011

jQuery document.ready and update panels

If you want to use jQuery document.ready but have update panels on the page then the even is not fired on partial page refreshes.

In this case, another handler needs to be added so call the ready event at the end of every request.

The code below can be used to achieve this.

Thursday, 18 August 2011

Dynamically create and show a jQuery UI dialog from Javascript

If you need to create a jQuery UI Dialog dynamically from javascript, heres how!

Tuesday, 19 April 2011

Bring window to front with jQuery and Javascript

If you open a popup window via javascript it often appears behind the current page so the user may not notice it. A simple solution for this problem is to bring the window to the fron when it has finished loading. This can be achieved with a simple bit of jQuery and Javascript.

Tuesday, 12 April 2011

Disable a button with jQuery and still do postback

If you want to disable a button in a web application to stop it being clicked more than once when a long running process starts this is possible with jQuery.

The one pitfall that comes with disabling a submit button on the client side is that it will cancel the browser’s submit, and thus the postback. Setting the UseSubmitBehavior property to false tells .NET to inject the necessary client script to fire the postback anyway, instead of relying on the browser’s form submission behavior.

for example:
(aspx)


(javascript)