Re: [jQuery] Converting old solution to jQuery

2007-03-31 Thread Shelane Enos
Thanks for being so generous :-)


On 3/30/07 7:47 AM, "Jake McGraw" <[EMAIL PROTECTED]> wrote:

> Well, thats quite a lot to ask, but I'm in a giving mood:
> 
> Javascript:
> $(function(){
> $("[EMAIL PROTECTED]").click(function(){
> if(confirm("Are you sure you'd like to delete this photo?")) {
> var photo_id = $(this).parent().find("input").val();
> $.get("/apps/photos/runtime.lasso",{id:photo_id},function(msg){
> // I'm pretty sure "this" still points to the img
> $(this).parent().empty().text(msg);
> });
> }
> return false;
> });
> });
> 
> HTML:
> 
> 
> 
> 
> 
> So, I changed a couple of things to simplify your markup:
> * You don't need an anchor, you can bind the click event to the image
> * I don't see what the "loop count" is for, so I removed that
> * The return message (msg) is assumed to be plain text, not xml
> * function(msg) will run on a successful AJAX call, $.get
> * the first line $(), is the same as window.onload
> * I assumed your application, runtime.lasso, takes in a single
> argument called "id"
> 
> One of the best things about jQuery is the plethora of documentation
> options out there, I'd suggest starting here:
> 
> http://docs.jquery.com/Tutorials
> 
> - jake
> 
> On 3/29/07, Shelane Enos <[EMAIL PROTECTED]> wrote:
>> I have a solution that was written with a minimalist, basic AJAX file.  I
>> would love to upgrade to jQuery, but I'm still such a newbie that my brain
>> isn't functioning.
>> 
>> I have a list of photos returned from my database with dynamic loop
>> counting.  Each row is currently this:
>> 
>> 
>> 
>> > height="19"border="0" align="middle" />
>> 
>> That onclick function is passing page that needs to do the processing, the
>> div ID (where it's going to display the response message), and the current
>> loop count - 1 to set the value of the hidden field.
>> 
>> It calls this function:
>> 
>> function rmPhoto(data, message, loop){
>> if (confirm("Are you sure you want to delete this photo?")){
>> if(!document.album.photo.length > 0)
>> document.album.photo[loop].value = 0;
>> else
>> document.album.photo.value = 0;
>> processData('/apps/photos/runtime.lasso', data, message);
>> }
>> return false;
>> }
>> 
>> processData is basic AJAX function to call the file, pass the data, and
>> return info to the div to display.
>> 
>> So, I'll need to find all divs with class "Text2"
>> find the a tag within that div
>> bind a click function to that a tag
>> which will:
>>  do a load to that div - this I believe will obliterate any all
>> items in the div, which is actually fine because when the main form is
>> processed, I would need information about a deleted photo anyway.
>> 
>> Any help in writing this in jQuery would be appreciated.
>> 
>> [Shelane]
>> 
>> 
>> ___
>> jQuery mailing list
>> discuss@jquery.com
>> http://jquery.com/discuss/
>> 
> 
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Converting old solution to jQuery

2007-03-30 Thread Jake McGraw
Well, thats quite a lot to ask, but I'm in a giving mood:

Javascript:
$(function(){
$("[EMAIL PROTECTED]").click(function(){
if(confirm("Are you sure you'd like to delete this photo?")) {
var photo_id = $(this).parent().find("input").val();
$.get("/apps/photos/runtime.lasso",{id:photo_id},function(msg){
// I'm pretty sure "this" still points to the img
$(this).parent().empty().text(msg);
});
}
return false;
});
});

HTML:





So, I changed a couple of things to simplify your markup:
* You don't need an anchor, you can bind the click event to the image
* I don't see what the "loop count" is for, so I removed that
* The return message (msg) is assumed to be plain text, not xml
* function(msg) will run on a successful AJAX call, $.get
* the first line $(), is the same as window.onload
* I assumed your application, runtime.lasso, takes in a single
argument called "id"

One of the best things about jQuery is the plethora of documentation
options out there, I'd suggest starting here:

http://docs.jquery.com/Tutorials

- jake

On 3/29/07, Shelane Enos <[EMAIL PROTECTED]> wrote:
> I have a solution that was written with a minimalist, basic AJAX file.  I
> would love to upgrade to jQuery, but I'm still such a newbie that my brain
> isn't functioning.
>
> I have a list of photos returned from my database with dynamic loop
> counting.  Each row is currently this:
>
> 
> 
>  height="19"border="0" align="middle" />
>
> That onclick function is passing page that needs to do the processing, the
> div ID (where it's going to display the response message), and the current
> loop count - 1 to set the value of the hidden field.
>
> It calls this function:
>
> function rmPhoto(data, message, loop){
> if (confirm("Are you sure you want to delete this photo?")){
> if(!document.album.photo.length > 0)
> document.album.photo[loop].value = 0;
> else
> document.album.photo.value = 0;
> processData('/apps/photos/runtime.lasso', data, message);
> }
> return false;
> }
>
> processData is basic AJAX function to call the file, pass the data, and
> return info to the div to display.
>
> So, I'll need to find all divs with class "Text2"
> find the a tag within that div
> bind a click function to that a tag
> which will:
>  do a load to that div - this I believe will obliterate any all
> items in the div, which is actually fine because when the main form is
> processed, I would need information about a deleted photo anyway.
>
> Any help in writing this in jQuery would be appreciated.
>
> [Shelane]
>
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


[jQuery] Converting old solution to jQuery

2007-03-29 Thread Shelane Enos
I have a solution that was written with a minimalist, basic AJAX file.  I
would love to upgrade to jQuery, but I'm still such a newbie that my brain
isn't functioning.

I have a list of photos returned from my database with dynamic loop
counting.  Each row is currently this:





That onclick function is passing page that needs to do the processing, the
div ID (where it's going to display the response message), and the current
loop count - 1 to set the value of the hidden field.

It calls this function:

function rmPhoto(data, message, loop){
if (confirm("Are you sure you want to delete this photo?")){
if(!document.album.photo.length > 0)
document.album.photo[loop].value = 0;
else
document.album.photo.value = 0;
processData('/apps/photos/runtime.lasso', data, message);
}
return false;
}

processData is basic AJAX function to call the file, pass the data, and
return info to the div to display.

So, I'll need to find all divs with class "Text2"
find the a tag within that div
bind a click function to that a tag
which will:
 do a load to that div - this I believe will obliterate any all
items in the div, which is actually fine because when the main form is
processed, I would need information about a deleted photo anyway.

Any help in writing this in jQuery would be appreciated.

[Shelane]


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/