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:
> <div>
> <input type="hidden" value="photo_id"/>
> <img src="/apps/photos/images/delete.gif" style="cursor:pointer;"/>
> </div>
>
> 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:
>>
>> <div id="photo[loop_count]" class="Text2" >
>> <input name="photo" type="hidden" value="[field: 'ID']" />
>> <a href="#" title="Remove this Photo" onclick="return
>> rmPhoto('process.lasso?[field: 'ID']', 'photo[loop_count]', '[loop_count -
>> 1]');"><img src="/apps/photos/images/delete.gif" width="19"
>> height="19"border="0" align="middle" /></a></div>
>>
>> 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
>> [email protected]
>> http://jquery.com/discuss/
>>
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/