views:

107

answers:

1

I am trying to present a form inside an overlay. The form is loaded via ajax. This all works fine on firefox 3.x.

But on Safari 5.0(5533.16), the overlay shows but does not make an ajax request, rather makes a html request.

Here is how I configure it in my js and then on document.ready I call ModalPostForm.init();

pastie - http://pastie.org/1196064

var ModalPostForm = {
    init: function(){
        $("a[rel='#post_overlay']").each(function(){
            //alert($(this).attr('href'));
            $(this).overlay({
                closeOnClick: false,
                target: '#post_overlay',
                fixed: false,
                onBeforeLoad: function() {
                    // grab wrapper element inside content
                    var wrap = this.getOverlay().find(".contentWrap");
                    // load the page specified in the trigger
                    wrap.load(this.getTrigger().attr("href"));
                },
                onLoad: function() {
                    setTimeout("configurePostForm(200, 1000, 150)", 500);
                },
                onClose: function() {
                    $('.contentWrap').empty();
                }
            });
        });
    },

    close: function(){
        $("a[rel='#post_overlay']").each(function(){
            var ol = $(this).data("overlay");
            if(ol.isOpened()){
                ol.close();
            }
        });
    }
};

Here is my html

<div id="post_overlay" class="new-post-overlay span-12" style="top: 54.3px; left: 429px; position: absolute; display: none;"><a class="close"></a>
  <div style="display: none;" id="form_loading" class="">
    <div class="loading-inner-center"></div>
  </div>
  <div id="" class="contentWrap"></div>
</div>

Why is it issuing html request?

Thanks

UPDATE

This goes away if I remove the format.html block in my rails respond_to block in my controller actions.

Though the question remains why it it sending a html request or why rails thinks it is a html request. I would rather not remove that block, for browsers that indeed can't do js.

new action which causes the issue

        respond_to do |format|
#            format.html # new.html.erb
            format.js {

            }
#            format.xml  { render :xml => @post }
        end

edit action which also causes the issue, both new and edit happen to be 'get' methods.

#            format.html {
#                if @edit
#                    #
#                    setup_post_items(true)
#                else
#                    flash[:error] = 'Sorry no further edits, Post has already been approved.'
#                    redirect_back_or_default root_url
#                end
#            }
            format.js {
                if !@edit
                    flash[:error] = 'Sorry no further edits, Post has already been approved.'
                end
            }