Working wonderfully.  Thanks.

On 4/20/07 1:25 PM, "Ariel Jakobovits" <[EMAIL PROTECTED]> wrote:

> 
> not only am i saying that you should be able to do that, i am saying i think
> the second version is better.
> 
> why?
> 
> in version 1, you say  var linkval = $j('#edit').attr("href"); but the return
> value if #edit does not exist is not apparent. Will it be "" or will it be
> undefined?
> 
> in version 2, you postpone getting that value until you are within the click
> handler, which will only get activated if #edit exists and is clicked.
> 
> but, in version 2, it is simple: .click() will be called on each member of the
> array returned by j("#edit") which may be empty which is no biggy, like...
> 
> for (var i=0; i < 0; i++)
> {
>     // never will happen;
> }
> 
> ----- Original Message ----
> From: Shelane Enos <[EMAIL PROTECTED]>
> To: jquery-en@googlegroups.com
> Sent: Friday, April 20, 2007 1:07:37 PM
> Subject: [jQuery] Re: find.click vs bind("click")
> 
> 
> Thanks to another problem I had, I've changed my code to this (which fixed
> my issue):
> 
> bindEdit = function(){
>         var linkval = $j('#edit').attr("href");
>         if (linkval != ''){
>             $j('#edit').click(function(){
>                 $j('#jobinfodisplay').load(linkval);
>                 return false;
>             });
>         }
>     };
> 
> But you're saying that I should be able to do this:
> 
> bindEdit = function(){
> 
>             $j('#edit').click(function(){
>                 var linkval = $j('#edit').attr("href");
>                 $j('#jobinfodisplay').load(linkval);
>                 return false;
>             });
> 
>     };
> 
> 
> On 4/20/07 1:00 PM, "Ariel Jakobovits" <[EMAIL PROTECTED]> wrote:
> 
>> 
>> no it should not throw an error.
>> 
>> j("#edit") will return an empty array is all and the bind will not be called.
>> 
>> ----- Original Message ----
>> From: Shelane Enos <[EMAIL PROTECTED]>
>> To: jquery-en@googlegroups.com
>> Sent: Friday, April 20, 2007 9:10:58 AM
>> Subject: [jQuery] Re: find.click vs bind("click")
>> 
>> 
>> OK, going back to this function:
>> *$j(function(){
>>     bindEdit = function(){
>>         $j('#edit').bind("click", function(){
>>             var linkval = $j(this).attr("href");
>>             $j('#jobinfo').load(linkval, function(){
>>                 bindEdit();
>>             });
>>             return false;
>>         });
>>     }
>>     //bindEdit();
>> });
>> 
>> If it's a case where the item 'edit' doesn't exist on the loaded page, it
>> would cause an error, correct?  If so, how do I first check if it exists,
>> then only do the binding if it exists?
>> 
>> 
>> 
>> 
>> On 4/17/07 10:12 PM, "Ariel Jakobovits" <[EMAIL PROTECTED]> wrote:
>> 
>>> 
>>> be aware that sometimes when a javascript error occurs in front of the
>>> return
>>> false, it will cause the link to activate.
>>> 
>>> are you using firebug?
>>> 
>>> if so, find the one catch(e) in the jquery.js file that is worth setting a
>>> breakpoint at and see if the script stops there.
>>> 
>>> 
>>> ----- Original Message ----
>>> From: Shelane Enos <[EMAIL PROTECTED]>
>>> To: jquery-en@googlegroups.com
>>> Sent: Tuesday, April 17, 2007 11:26:16 AM
>>> Subject: [jQuery] Re: find.click vs bind("click")
>>> 
>>> 
>>> Unfortunately this is an internal application.  The jQuery code on the page
>>> is just this (I have the one function commented out b/c I couldn't get that
>>> to work):
>>> 
>>> var $j = jQuery.noConflict();
>>> 
>>> function setStatus(statname, statID, stattitle){
>>>     if (statID != '')
>>>         var method = 'remove';
>>>     else
>>>         var method = 'add';
>>>     $j.post('/admin/includes/tools/runtime.lasso' + subargs, { catalog:
>>> 'hirestatus', method: method, statusID: statID, hrstatus: stattitle,
>>> statname: statname, statusDate: myDate });
>>>     return false;
>>> }
>>> 
>>> modify = function(){
>>>     $j("#changedmessage").text("Click Update to save changes");
>>>     document.jobinfo.method.value="Update";
>>>     document.jobinfo.method.disabled=false;
>>> }
>>> 
>>> /*$j(function(){
>>>     bindEdit = function(){
>>>         $j('#edit').bind("click", function(){
>>>             var linkval = $j(this).attr("href");
>>>             $j('#jobinfo').load(linkval, function(){
>>>                 bindEdit();
>>>             });
>>>             return false;
>>>         });
>>>     }
>>>     //bindEdit();
>>> });*/
>>> 
>>> function loadEdit(){
>>>     var linkval = $j('#edit').attr("href");
>>>     $j('#jobinfo').load(linkval);
>>>     return false;
>>> }
>>> 
>>> 
>>> The "link" I'm trying to load is on a page like this:
>>> 
>>> <a 
>>> href="/job.lasso?page=job&cid=6a3b9887af24e894&section=sl_in&jobpage=descrip
>>> t&view=edit" id="edit" onclick="loadEdit(); return false;"><img
>>> src="/images/edit.gif" border="0" height="17" width="10"></a>
>>> 
>>> On 4/17/07 11:04 AM, "John Resig" <[EMAIL PROTECTED]> wrote:
>>> 
>>>> 
>>>> Do you have an example with a full page, there's probably another issue
>>>> here.
>>>> 
>>>> --John
>>>> 
>>>> On 4/17/07, Shelane Enos <[EMAIL PROTECTED]> wrote:
>>>>> 
>>>>> I changed to this:
>>>>> function loadEdit(){
>>>>>     var linkval = $j('#edit').attr("href");
>>>>>     $j('#jobinfo').load(linkval);
>>>>>     return false;
>>>>> }
>>>>> 
>>>>> And added the function itself to my link.  onclick=loadEdit();
>>>>> The return false in the function isn't working.  If I put it in the
>>>>> onclick
>>>>> (onclick=loadEdit(); return false;) then the page is loaded properly.
>>>>> Otherwise the function (even with the return false in the function) is
>>>>> allowing link to be followed anyway.
>>>>> 
>>>>> 
>>>>> On 4/17/07 10:22 AM, "Shelane Enos" <[EMAIL PROTECTED]> wrote:
>>>>> 
>>>>>> 
>>>>>> So I'm trying this:
>>>>>> 
>>>>>> $j(function(){
>>>>>>     bindEdit = function(){
>>>>>>         $j('#edit').bind("click", function(){
>>>>>>             var linkval = $j(this).attr("href");
>>>>>>             $j('#jobinfo').load(linkval, function(){
>>>>>>                 bindEdit();
>>>>>>             });
>>>>>>             return false;
>>>>>>         });
>>>>>>     }
>>>>>>     bindEdit();
>>>>>> });
>>>>>> 
>>>>>> Which to me says bind an onclick function to an a tag with ID 'edit'.
>>>>>> Read
>>>>>> the value of it's href (pages are dynamically loaded an hrefs change).
>>>>>> Load
>>>>>> the link into the div id "jobinfo" and now call bindEdit to bind the
>>>>>> click
>>>>>> event to the edit link on the newly loaded page.  Return false so it
>>>>>> doesn't
>>>>>> follow the link as a normal link.
>>>>>> 
>>>>>> OK, so it doesn't work.  The page loads normally instead of into the div
>>>>>> via
>>>>>> ajax and I get "too much recursion" errors in the console.
>>>>>> 
>>>>>> Am I doing something wrong here?
>>>>>> 
>>>>>> 
>>>>>> On 4/17/07 9:57 AM, "spinnach" <[EMAIL PROTECTED]> wrote:
>>>>>> 
>>>>>>> 
>>>>>>> .bind('click') is faster because you bind it directly to the element,
>>>>>>> .find() must first find the element inside the #jobinfo element and then
>>>>>>> bind the appropriate event..
>>>>>>> 
>>>>>>> there is no difference between .bind('click') and .click(), .click is
>>>>>>> just an alias for .bind('click').. and if i'm not mistaken, .click was
>>>>>>> taken out of the core since 1.1 (i may be wrong, i know some aliases
>>>>>>> were removed, but not sure which - so i just use .bind for everything
>>>>>>> :))..
>>>>>>> 
>>>>>>> dennis.
>>>>>>> 
>>>>>>> Shelane Enos wrote:
>>>>>>>> What is the difference, advantage/disadvantage of these different
>>>>>>>> methods:
>>>>>>>> 
>>>>>>>> bindEdit = function(){
>>>>>>>> $j('#edit').bind("click", function(){
>>>>>>>>             var linkval = $(this).attr("href");
>>>>>>>>             $j('#jobinfo').load(linkval, function(){
>>>>>>>>                 bindEdit();
>>>>>>>>             });
>>>>>>>>             return false;
>>>>>>>>         });
>>>>>>>> }
>>>>>>>> 
>>>>>>>> bindEdit = function(){
>>>>>>>> $j('#jobinfo').find('#edit').click(function(){
>>>>>>>>             var linkval = $(this).attr("href");
>>>>>>>>             $j('#jobinfo').load(linkval, function(){
>>>>>>>>                 bindEdit();
>>>>>>>>             });
>>>>>>>>             return false;
>>>>>>>>         });
>>>>>>>> }
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>> 
>> 
>> 
>> 
>> 
> 
> 
> 
> 
> 

Reply via email to