[jQuery] can i use livequery with greybox2 or equivalent?
Hi. I am using greybox2 plugin to generate a modal window with details of items when I click on their hyperlink, identified by the class= . However, I am also adding more such hyperlinks with teh same class= on the fly, and I need to rebind the elements correctly. Can I use livequery to do this, or do I need to do it another way? This is what my code looks like: $(document).ready( function(){ var gbOptions = { gbWidth: 400, gbHeight: 400, captionHeight: 22 }; $('.pageWindow').greybox(gbOptions); // for item info opening in modal wondow blah blah blah --- Can I use livequery like something like this ( This doesn't work)?: $('.pageWindow').livequery('click', $('.pageWindow').greybox(gbOptions); ) // for item info opening in modal wondow }); - Thanks, Jamie
[jQuery] Re: jquery/livequery assign behaviour to element by class
Hi Brandon, I tried to do that, but it breaks the ajax effect - clicking submit just does an HTML post to the server php program: $('.deleteform').livequery('submit', function() { //$('.deleteform').submit(function() { var gthis = this; var delformData = $(this).serialize(); //function() {echo "hello"; } $.post('eatchoices.php', delformData, delprocessData); function delprocessData(data) { $(gthis).parent().html(data); // get the parent of the form so replace just below the date } // end of delformData return false; }); // end of submit delete form I am stumped and confused, Jamie On Sep 16, 10:03 pm, "Brandon Aaron" <[EMAIL PROTECTED]> wrote: > Replace the first line > $('.deleteform').submit(function() { > > with this > > $('.deleteform').livequery('submit', function() { > > -- > Brandon Aaron > > On Tue, Sep 16, 2008 at 8:30 PM, onmountain <[EMAIL PROTECTED]> wrote: > > > Can I use livequery with ajax? For instance, I am adding and deleting > > elements of a certain class that have .post associated with them > > at .ready. > > > For instance, if my last .post returns new html that create more items > > with delete forms, how should I turn the code in the .ready below to > > work? > > $('.deleteform').submit(function() { > > var gthis = this; > > var delformData = $(this).serialize(); > > $.post('eatchoices.php', delformData, delprocessData); > > function delprocessData(data) { > > $(gthis).parent().html(data); // get the parent of > > the form so replace just below the date > > } // end of delformData > > return false; > > }); // end of submit delete form > > > On Sep 15, 4:11 pm, "Brandon Aaron" <[EMAIL PROTECTED]> wrote: > > > Typically with tables you want to do event delegation for performance > > > reasons. However, this is how you'd do it with LiveQuery. > > > $(document).ready(function() { > > > $('table tbody td.hasContent') > > > .livequery('mouseenter', showBox) > > > .livequery('mouseleave', hideBox) > > > .livequery('mousemove', position) > > > .livequery('click', showDetail); > > > > }); > > > > You could also do a function based livequery like this: > > > > $(document).ready(function() { > > > $('table tbody td.hasContent') > > > .livequery(function() { > > > $(this) > > > .bind('mouseenter', showBox) > > > .bind('mouseleave', hideBox) > > > .bind('mousemove', position) > > > .bind('click', showDetail); > > > }); > > > > }); > > > > The mouseenter and mouseleave events are what the hover helper method use > > > behind the scenes. > > > > -- > > > Brandon Aaron > > > > On Mon, Sep 15, 2008 at 11:49 AM, jwynne <[EMAIL PROTECTED]> wrote: > > > > > Currently I am using $(document).ready to bind some behaviours to > > elements > > > > in > > > > the DOM based on a class name (using jquery's .filter) - This works > > great > > > > on > > > > the initial load of the page however these bindings get all screwy when > > I > > > > try injecting or editing new elements to the DOM dynamically via AJAX. > > > > After researching the issue I have been trying to use the livequery > > plug-in > > > > but have been unsuccessful so far. > > > > > In $(document).ready I am assigning behaviour to td elements of the > > class > > > > "hasContent". I am looking to hook them up to livequery listeners so > > that > > > > the correct behaviours are assigned when the DOM is updated. > > > > > $(document).ready(function(event) { > > > > > var position = function() { > > > > } > > > > var showBox = function() { > > > > } > > > > var hideBox = function() { > > > > } > > > > var showDetail = function() { > > > > } > > > > > //Syntax help below > > > > $("table tbody td").filter(".hasContent").hover(showBox, > > > > hideBox).mousemove(position); > > > > $("table tbody td").filter(".hasContent").click(showDetail); > > > > > });//EOF > > > > > Can anybody help me with the syntax necessary to get livequery to > > > > bind/unbind the necessary behaviours to the table tds? > > > > > Thanks for the help. > > > > -- > > > > View this message in context: > > > >http://www.nabble.com/jquery-livequery-assign-behaviour-to-element-by. > > .. > > > > Sent from the jQuery General Discussion mailing list archive at > > Nabble.com.
[jQuery] Re: jquery/livequery assign behaviour to element by class
Can I use livequery with ajax? For instance, I am adding and deleting elements of a certain class that have .post associated with them at .ready. For instance, if my last .post returns new html that create more items with delete forms, how should I turn the code in the .ready below to work? $('.deleteform').submit(function() { var gthis = this; var delformData = $(this).serialize(); $.post('eatchoices.php', delformData, delprocessData); function delprocessData(data) { $(gthis).parent().html(data); // get the parent of the form so replace just below the date } // end of delformData return false; }); // end of submit delete form On Sep 15, 4:11 pm, "Brandon Aaron" <[EMAIL PROTECTED]> wrote: > Typically with tables you want to do event delegation for performance > reasons. However, this is how you'd do it with LiveQuery. > $(document).ready(function() { > $('table tbody td.hasContent') > .livequery('mouseenter', showBox) > .livequery('mouseleave', hideBox) > .livequery('mousemove', position) > .livequery('click', showDetail); > > }); > > You could also do a function based livequery like this: > > $(document).ready(function() { > $('table tbody td.hasContent') > .livequery(function() { > $(this) > .bind('mouseenter', showBox) > .bind('mouseleave', hideBox) > .bind('mousemove', position) > .bind('click', showDetail); > }); > > }); > > The mouseenter and mouseleave events are what the hover helper method use > behind the scenes. > > -- > Brandon Aaron > > On Mon, Sep 15, 2008 at 11:49 AM, jwynne <[EMAIL PROTECTED]> wrote: > > > Currently I am using $(document).ready to bind some behaviours to elements > > in > > the DOM based on a class name (using jquery's .filter) - This works great > > on > > the initial load of the page however these bindings get all screwy when I > > try injecting or editing new elements to the DOM dynamically via AJAX. > > After researching the issue I have been trying to use the livequery plug-in > > but have been unsuccessful so far. > > > In $(document).ready I am assigning behaviour to td elements of the class > > "hasContent". I am looking to hook them up to livequery listeners so that > > the correct behaviours are assigned when the DOM is updated. > > > $(document).ready(function(event) { > > > var position = function() { > > } > > var showBox = function() { > > } > > var hideBox = function() { > > } > > var showDetail = function() { > > } > > > //Syntax help below > > $("table tbody td").filter(".hasContent").hover(showBox, > > hideBox).mousemove(position); > > $("table tbody td").filter(".hasContent").click(showDetail); > > > });//EOF > > > Can anybody help me with the syntax necessary to get livequery to > > bind/unbind the necessary behaviours to the table tds? > > > Thanks for the help. > > -- > > View this message in context: > >http://www.nabble.com/jquery-livequery-assign-behaviour-to-element-by... > > Sent from the jQuery General Discussion mailing list archive at Nabble.com.
[jQuery] an example of a php response to ajaxForm request
Is there any special thing that needs to be done to reply correctly to an ajaxForm request expecting html back? I can get it to work with echoing back a jason array, but nothing I do will get just a straight text response to work. Do I need to send a "success" somehow, could that be messing me up? Thanks for any php fragments you might have. Jamie
[jQuery] ajax not working on new form added to a page after an ajax operation
Hi. I have a calendar which lists events. After each event I have a "delete" form. When someone clicks the submit, I use ajaxform to return new html that replaces the entire day's list of events, including a new delete form for each event. My problem is, the new forms do not seem to be "ajaxed". When pressed, those newly replaced items just go straight to an old fashioned POST, not ajax. When I refresh the page manually, they work. Do I have to do something to "refresh" the things in $ (document).ready() ? Thanks, Jamie
[jQuery] Re: Read AJAX response in transit?
Hi. I guess if the process is REALLY long, like minutes or hours, it could be done. How about this as an idea: 1. on the server, create two handlers. The first one is the action you call to start the long process off with - call it "start". The second will be a progress check - call it "check". 2. When "start" is called with ajax the first time, it will have to pass an ID back via the ajax response the calling routine. Assuming that these are webpages, you have to have a way to differentiate between different "start" requests. You might have one, you might have 20 different "start" ajax requests going. Note that is the process is really long, in that it soaks up huge CPU resources, etc, you may be better off have some sort of lock-out flag set when you start, preventing other costly start requests beginning at the same time. The ajax response in those cases would tell the user yo try again later, etc. 3. The start program on the server will need to periodically update some sort of file or DB record on its state, like % done, using the ID it is working on and had previously passed back. 4. The "check" (with an ID passing back too) would cause the server to look for a % in that file or DB with that particular ID. It could reply with status % or other info, like "No such process". Anyway, that is what came to my mind. If it is really long, perhaps it would be better to queue up the incoming jobs, and just put results on webpages with a URL passed back in the first step - the user or his/ her program could just keep checking that URL until there was a finished product. Good luck, Jamie On Sep 16, 11:09 am, Michael Price <[EMAIL PROTECTED]> wrote: > Hi all, > Is there any way to use jQuery to "stream" an AJAX response as it's > downloading? > > For example, I'm running a long script via AJAX and I want to post > progress updates on the screen as it goes - at certain intervals I > output a percentage via the AJAX script which my page can then read and > update on screen. > > Does this make sense, and is it possible? > > Regards, > Michael Price
[jQuery] Re: serialize does not send the value of the submit button
Thank Mike, That was a help. Thought I was going crazy there for a while. The problem with working with ajax in a new language is that you never know what part of the transaction is problematic. I have set up an example with ajaxForm and have it working fine with json. However, is there something specifically on the server side (php) I should do if I am wanting to pass html back? I can't just use a bunch of echo lines can I? I don't get anything back when I do that. I have to build a response into a variable and send that (careful not to have any " in there) back as jason. I can't seem to reproduce the server php code needed to reply back to the sample at : http://malsup.com/jquery/form/#code-samples On Sep 16, 11:53 am, Mike Alsup <[EMAIL PROTECTED]> wrote: > > Hi. Pretty new to jquery, but have gotten some ajax working - my > > question is, is it normal that the serialize does not send the value > > of the submit button itself? If so, why is that? > > Yes, that is normal because the serialize method has no way of knowing > which submit element was clicked. If you need that functionality you > can check out the Form Plugin, specifically, its ajaxForm method. > > http://www.malsup.com/jquery/form/ > > Mike
[jQuery] serialize does not send the value of the submit button
Hi. Pretty new to jquery, but have gotten some ajax working - my question is, is it normal that the serialize does not send the value of the submit button itself? If so, why is that? It caused me all sorts of problems, as my php code responds to various HTML post requests based on the value of the submit button (e.g. add, delete, or view commands). The jquery serialize was sending the other fields OK, but my php server program was just ignoring each request, based on the missing value of submit. Seems odd that the submit button would be treated differently. My work around is to have the server php code look for "missing" submit values and falling back on an additional hidden text field I had to add to the forms called "command". It does let me treat ajax posts and normal HTML posts differently, a slight advantage in my case, but I can't find anything on teh web or my jquery books that warns people of this difference... Thanks for any advice (especially if I am doing something really stupid :-) Jamie