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: [email protected]
> 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§ion=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;
>>>>>> });
>>>>>> }
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>
>
>
>
>