subgridRowColapsed event never fired - jqgrid

Im using free-jqgrid and trying to simply hande subgrid collapsed event (subGridRowColapsed). However it's never get triggered.
I've tried jqGridSubgridRowColapsed also and same result.
subGridRowExpanded works fine.
...
subGridRowColapsed: function (pID, rID) {
console.log("YES");
},
...

It's good if you post the version of free jqGrid, which you use.
In any way, free jqGrid don't support neither subGridRowColapsed callback nor the event jqGridSubgridRowColapsed. There are exist callbacks subGridBeforeCollapse, subGridBeforeExpand, subGridRowExpanded and events jqGridSubGridBeforeCollapse, jqGridSubGridBeforeExpand, jqGridSubGridRowExpanded, which can be used. See here and here as short documentation.

Related

Attach event handler in chrome not working

This code:
function attachDateNavEventHandler() {
$('.ui-datepicker-title option').each(function () {
$(this).mouseup(setFlag);
});
attaches the event fine in FF but not in IE 8 or Chrome. I'm working with the jQuery datepicker and want to set a flag if the user navigates with the month or year drop-downs. I can't seem to attach to the onchange event of the selects. I think there must be an internal block on those events. I also had trouble using a simple click
Any suggestions mooooooost welcome :).
Try:
$(this).on('mouseup', setFlag);
Though this is basically the same thing you have.
I have a feeling that the options themselves may have the funny business. Options can't do everything that a typical HTML element can, but I'm not certain of the limitations on what browsers.
What about setting an on change on the whole select itself instead of trying to listen for mouseup events of each individual option.
$('.ui-datepicker-title').change(

how to access the id of div which is loaded through ajax

I have button with id = new which loads the new page
$("#new").click(function(){
$('#message_area').load('new.php');
});
There is a button in new.php which sends message to database. But i have a problem with it , it only works for first time when page loads if i navigate to some other links via ajax and again load new.php using above code then send button in new.php does not work i have to refresh the page then it works. I think its because the send button in new.php is added after DOM is created for first time .
Please help Thanks in advance ..
You will need to post more details of your markup for a more accurate answer, but the general idea is to use event delegation. Bind the event handler to an ancestor of the button that does not get removed from the DOM. For example:
$("#message_area").on("click", "#yourButton", function() {
//Do stuff
});
This works because DOM events bubble up the tree, through all of an elements ancestors. Here you are simply capturing the event higher up the tree and checking if it originated from something you are interested in (#yourButton).
See jQuery .on for more. Note that if you're using a version of jQuery below 1.7, you will need to use delegate instead.
//jquery >= v1.7
$("body").on('click', '#new', function(){
$('#message_area').load('new.php');
});
//jquery < v1.7
$("#new").live('click',function(){
$('#message_area').load('new.php');
});
$("#new").live("click", function(){
$('#message_area').load('new.php');
});
just realized this was deprecated-- should be using on instead.. my bad.
To manage dynamically created elements like this, you need to use .on() (jQuery 1.7 and above) or .delegate() (jQuery 1.4.3 and above) to assign the events. Seems everyone has beaten me to the code, but I'll post this for the links to the functions.

jquery contextMenu + .live

I am using a plugin called jQuery contextMenu but am having trouble making it work with elements that are loaded via ajax after the DOM has already loaded. does anyone know how i can get this working with .live?
I've made a modification of the original jquery.contextMenu.js script. I've replaced .each() with .live("mousedown", ...) and deleted appropriate mousedown binding (you can also make a diff of my code and the original to get the changes).
You can get the code from http://pastebin.com/jBcAR6g1
Works for me.
2018 update without plugin:
$(document).on('contextmenu','#object_id',function() {
//code
});
I think you must use enableContextMenuItems() method on the newly added elements. If you post your code it would be easier to help.

jQuery .live event propagation

I have a little problem with jQuery .live method. I am using it for catching ajax events for Google Analytics on my website, but in case I have a link with an inner image, the click event is fired up from the image and my live binded click event does not catch it.
I really dont like to add these events manually everytime after changing content and I dont like to bind it to the image (because of the missing href parameter, this case I had use some .parent method), so what is the best way how to handle this?
Notice: I am not sure about efficiency of the .live method, so in case there are big performance differences, please tell me that:) I tried to profile it in webkit profiler, but I didn't see any difference..
Just place a click(function(event) { ... }) handler on the static parent element, and find the element which started the event with event.target.
Assuming you have an a containing an img, any event on the img should bubble to the a, which will catch it.
You could also try using the .delegate() method (http://api.jquery.com/delegate/)
Here is some more info regarding .live() vs. delegate():
http://brandonaaron.net/blog/2010/03/4/event-delegation-with-jquery
http://www.youtube.com/watch?v=23Q4S9hmHQY
jQuery: live() vs delegate() [stackoverflow.com]
Update:
Here is a post by Jupiter 24 about "Why you should never use jQuery live":
http://jupiterjs.com/news/why-you-should-never-use-jquery-live

jQuery: Targeting elements added via *non-jQuery* AJAX before any Javascript events fire? Beyond the scope of live()?

Working on a Wicket application that adds markup to the DOM after onLoad via Wicket's built-in AJAX for an auto-complete widget. We have an IE6 glitch that means I need to reposition the markup coming in, and I am trying to avoid tampering with the Wicket javascript... blah blah blah... here's what I'm trying to do:
New markup arrives in the DOM (I
don't have access to a callback)
Somehow I know this, so I fire my
code.
I tried this, hoping the new tags would trigger onLoad events:
$("selectorForNewMarkup").live("onLoad", function(){ //using jQuery 1.4.1
//my code
});
...but have become educated that onLoad only fires on the initial page load. Is there another event fired when elements are added to the DOM? Or another way to sense changes to the DOM?
Everything I've bumped into on similar issues with new markup additions, they have access to the callback function on .load() or similar, or they have a real javascript event to work with and live() works perfectly.
Is this a pipe dream?
.live() doesn't work like this, it's a common misconception. .live() creates an event handler at the DOM root and waits for events to bubble up to it. If the selector matches the event target, .live() will fire the bound event.
It doesn't look for new objects and bind events to them in any way, rather it just listens for a bubble, and doesn't care when that object was added to the DOM.
You need to fire whatever code is needed to run manually when your load operation completes.
What will this is the livequery plug-in, look specifically at the livequery( matchedFn ) call.
You can do something like this:
$('#myID').livequery(function() { $(this).offset()...stuff });
i guess this is what you are looking for http://ananthakumaran.github.com/2010/02/19/wicket-post-ajax-handling.html

Resources