OK, I've tried the onShow and no dice. I keep getting errors that are
more of an issue than the ones I'm trying to avoid.
So for now I'm just going to have to live with it as is and try to
make sure no one uses those links with my .pop-up class.
Thanks for your input Alexandre.


On Mar 25, 2:55 pm, Alexandre Plennevaux <aplennev...@gmail.com>
wrote:
> 1/ i would make sure the div exist before initalising the jqModal, so  add
> the jqm initialisation to your createDiv function or through a callback
> executed when the createDiv is done.2/ for your specific question: your
> check is incorrect. The good use would be to use jqmodal onShow() callback
> and check at that moment whether the link is valid or not.
>
> onshow:function(hash){
> if (hash.t.attr('href') ==='#' || hash.t.attr('href') ===''){
> return false;}
>
> // otherwise, launch the popup
> hash.w.css('opacity',0.88).show();
>
> }
>
> from the doc:
>
>   Each callback is passed the jqModal "hash" for a window. Relevant
> hash properties are;
>
>         -----------------------------------
>         w: (jQuery object) The window element. e.g. '#example' in the sample 
> above
>         c: (object) The config object (holds passed+default parameters)
>         o: (jQuery object) The overlay
>         t: (DOM object) The triggering element
>
>   NOTE; If you supply a "onHide" callback, you MUST execute hash.o.remove(); 
> to
>     remove the overlay. You should also hide the window via hash.w.hide();, or
>     with a special effect.
>
>   NOTE; If you supply a "onShow" callback, you should make the dialog visible
>     via hash.w.show();, or with a special effect.
>
>   NOTE; "onLoad" callbacks are ONLY executed if the ajax parameter was passed.
>     onLoad is called after the ajax response. As with $.load(), the "this"
>     scope is a reference to the ajax target as a DOM element.
>
> On Wed, Mar 25, 2009 at 6:13 PM, Tad <tad.ni...@gmail.com> wrote:
>
> > Hello,
> > I'm new to jquery and jqmodal. I have a script that runs fine except
> > when the URL (href) of the anchor tag is Blank or "#". so what I want
> > to do is check for that possibility and stop the Jqmodal from acting
> > or put up an error message, without my page being messed up. I've
> > tried to use callbacks, but get an error that the hash is not defined.
> > I tried to use the click event of the anchor, but the Jqmodal would
> > load the content but only show it after clicking another anchor tag or
> > clicking the same one again. the goal here is to have a default pop Up
> > jqmodal that checks the link it is given and doesn't use it if it will
> > cause an error.
>
> > ~~ code that works but doesn't check href of anchor~~
> > $(function(){
> > /* init pop-up/overlay */
> >    popUp.init();
> > });
> > /* pop-up/overlay Functionality */
> > var popUp = {
> >    init: function(){
> >        var link = $("a.popup");
> >        if(link.length <= 0)
> >            return false;
> >        popUp.createDiv();
>
> >        $('div#popup-wraper').jqm({
> >           trigger: $("a.popup"),
> >           closeClass: 'close',
> >           toTop: true,
> >           ajax: '@href',
> >           target: $("div#popup-wraper div#popup"),
> >           ajaxText: ("loading..."),
> >           cache: false
> >        })
> >    },
> >    createDiv: function(){
> >        var strJq = "<div id='popup-wraper' class='jqmWindow'>";
> >        strJq += " <div id='overlay-utility'>";
> >        strJq += "  <a class='close' href='#'>Close</a>";
> >        strJq += " </div>";
> >        strJq += " <div id='popup'>";
> >        strJq += " </div>";
> >        strJq += "</div>";
> >        $("body").append(strJq);
> >    }
>
> > }
>
> > /* pop-up/overlay Functionality END */
> > ~~ end code ~~

Reply via email to