Anthony,

The doc-ready construct provides a place to put code that needs to
*execute* after the DOM has fully loaded.  For example, this line:

var question = $('#question')[0];

should be in a doc-ready block because you want to ensure the element
is available before you select it.  But your "addtocart" function is
called in response to an click event handler, so the code within it
does not need to be wrapped in a doc-ready block.

For more on the "ready" method:

http://docs.jquery.com/Tutorials:Introducing_%24%28document%29.ready%28%29
http://docs.jquery.com/Events#ready.28_fn_.29

Mike


On 7/20/07, Anthony Leboeuf(Worcester Wide Web)
<[EMAIL PROTECTED]> wrote:

Hi Mike,

Thanks allot that worked great! now to help out a nooby here this is
considered DOM right? and in DOM you dont need doc ready functions ?

Thanks again

-Anthony

Mike Alsup wrote:
>
> Anthony,
> You've got script errors on that page.   You need to get those cleared
> up first.  Also, your blockUI code doesn't need to be in a doc-ready
> block (ie: $(function(){})) since you're calling it from an event
> handler.  Try something like this:
>
> var question = $('#question')[0];
>
> function addtocart(formName,product) {
>    var obj = findObj(formName);
>    if (obj != null) {
>        $.blockUI(question, { width: '275px' });
>
>        $('#yes').click(function() {
>            obj.submit();
>             window.location = "/order/cart.php?act=cart";
>            return false;
>        });
>        $('#no').click(function() {
>            $.unblockUI();
>            obj.submit();
>        });
>    }
>    else {
>        alert('warning');
>    }
> }
>
> Mike
>
>
> On 7/19/07, Anthony Leboeuf(Worcester Wide Web)
> <[EMAIL PROTECTED]> wrote:
>>
>>  Hello everyone, Im having a bit of trouble using blockui. I've added
>> the
>> plugin here
>> http://pioneer.dlg360.com/order/index.php?act=viewProd&productId=2678
>> when you click "add to basket" it should ask you a question(instead
>> it asks
>> the question for 2 seconds then submits). But for some reason its
>> forcing
>> the submit instead of waiting for the answer as the blockui demo
>> shows. I
>> just cant seem to fix it, anyone have any suggestions? here is my code
>> http://pastebin.mozilla.org/157254
>>
>>  Thanks any help is appreciated
>>
>>
>>  -Anthony
>>
>


Reply via email to