If a modal is open, and that modal child page contains a link. How can i get it to open in that modal. Now every link opend in a modal gets target="_new". Offcourse i can remove that with some custom jquery but i hope/guess there is allready some sort of option build in modalframe for this.
Comments
Comment #1
Michsk commentedAnd while we're at it, 2) can we open a link in the parent page and close the modal? So we don't get a new tab?
Comment #2
markus_petrux commentedYou can add the CSS class "modalframe-exclude" to the links that you wish to open inside the Modal Frame. See Drupal.modalFrameChild.behaviors.parseLinks() in modalframe/js/child.js
Comment #3
markus_petrux commentedRe: "And while we're at it, 2) can we open a link in the parent page and close the modal? So we don't get a new tab?"
This is a bit more tricky. From the child window you can trigger a close, and that may provide arguments to the onSubmit method of the parent window. That's the one that can reload the page to any URL that you may need.
I think you'll find ideas to do this in the Modal Frame Contrib Package.
Comment #4
Michsk commented@#2: I tried that and still am trying but it doesnt work in the modal... When im viewing the child in a own tab, the links with the above class don't have the target set. But when i view it in the modal on a parent page the child page links do have the target set. I cleared cache but doesnt seem to do the trick.
//edit: viewing in a own tab always seems to remove the target.
//edit: my custom .js file in which i add the class to the links, is called before the child.js. So it's not that.
Comment #5
Michsk commentedchild.js @103
if ($(this).hasClass('modalframe-exclude'))just wont validate... I don't get an error nothing.Comment #6
Michsk commentedOk so when the class is added directly in the html element everything works.
//problem seems to be that the link is processed before i can add modalframe-excluse trough my own .js, any Markus ideas?
Comment #7
Michsk commentedCould this have to do with:
?
//edit: Ok this has to do with
Drupal.behaviors = $.extend({modalFrameChild: Drupal.modalFrameChild.attach}, Drupal.behaviors);. Guess it places the modalFrameChild above my behavior and there for the processes the link before i can.Comment #8
Michsk commentedhereby my JS file
I can't figure it out, maybe you can help markus.
Comment #9
Michsk commentedGreat, got it working by using
Got that from the subnodes_by_taxonomy module.
//edit lol, it does work but i had my child an parent settings in one js file and now the parent settings dont work...
//edit got the parent and child settings working now.
Comment #10
bleen commentedsubscribing
Comment #11
mecmartini commented@lasac I can't make it work. Can you explain in details how you did?
Thx
Comment #12
mecmartini commentedOk got it working by using the 'modalframe-exclude' class.
Comment #13
tpainton commentedOh boy. Your example is appreciated but it's got a lot going on. I'm interested in just closing the modal and getting back to the parent window when a link is clicked. (not a new tab) Any possibility of a simple example doing that? It almost seems easier to patch modalframe to do what I need if a certain class is attached to the link. :( I don't really want to do that.
Comment #14
hermes_costell commentedThat I may smite asunder the blemish wrought upon the internet by this automatic target="_new" madness...
Comment #15
Michsk commentedhermes_costell i love the simplicity, great find.
Comment #16
carvalhar commentedhi,
i have a modal with links inside and i'd like to open these link inside the modal but without sidebars etc.
Solution #14 just replace the target, all complete page is loaded, not only the main content (without sidebars).
I couldn't get it working with solution #8.
//edit:
I was able to open another modal from a modal using the code from modalframe_more_help at Modal Frame Contrib Package
thanks
Carlos
Comment #17
dsnopekUsing Automodal, you can open a link in the same modalframe by doing:
However, as far as having a link open a 2nd modalframe (ie. another on top of the existing) - that's something modalframe isn't going to support in it's code base (however, you're welcome to try and support it in your own code like @Lasac is doing above). A modal that opens another modal isn't modal. :-)
Comment #19
mariaioann commentedSolution #17 worked perfectly for me.