1 Replies - 1426 Views - Last Post: 12 November 2012 - 01:27 PM

#1 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7893
  • View blog
  • Posts: 13,421
  • Joined: 19-March 11

swapping out a simplemodal

Posted 09 November 2012 - 12:53 PM

I'm not a jQuery nor a javascript guru, so forgive me if this is a silly question. Is there an accepted idiom for replacing one simplemodal with another?

I'm looking at a bug on our website where we have the client in a modal, and there's a button for contact information. Contact information is standardly displayed in a different modal, but the guy who built it has this one directing the client to a static page with the same information - probably because he didn't know a way to close the current modal and open a new one (ie, swap out one modal for another).

I'm looking at this, and thinking there has to be a way to do it. I can make this work by passing an onClose function, but then of course the client can't dismiss the modal without getting to the contact info, so that's no good. So now I'm thinking maybe the "contact" button could set the onClose function to what I need it to be, or else have the regular "close" button clear the onClose function (so the window just closes).
But something tells me maybe I'm working too hard, and there's probably an easy way to make this work. Any tips would be appreciated.

This post has been edited by jon.kiparsky: 09 November 2012 - 12:53 PM


Is This A Good Question/Topic? 0
  • +

Replies To: swapping out a simplemodal

#2 BetaWar  Icon User is online

  • #include "soul.h"
  • member icon

Reputation: 1168
  • View blog
  • Posts: 7,218
  • Joined: 07-September 06

Re: swapping out a simplemodal

Posted 12 November 2012 - 01:27 PM

I would suggest creating a new function called swap modal, and have it look something like so:

function swapModal(oldOne, newOne){
  oldOne.onClose();
  newOne.onOpen(); // assuming this is a real function...
}



Now, this likely isn't the full function, but hopefully it can get across the intent (I don't use jQuery frequently).

Then, the contact button can simply call the swapModal function with the two relevant modals.

Hope that helps.

PS: In general, there are almost as many standards as there are programmers. That is part of the problem with standards - there are so many of them.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1