Hi,
I'm using Ctools modal plugin to display login / registration form in a modal window, which works fine. I created a menu hook that when clicked displays my forms in the modal window, so that's all fine. I'm curious if there's a way to trigger the modal window without clicking a link. A use case would be when you're trying to view a node you don't have permission to view and the login / register form appears in the modal. Right now I achieved this functionality by adding inline js and programatically clicking the link but it's not the best approach I think. What I really want to do is call a function that triggers the modal display.
Thanks,
Rob
Comments
Comment #1
merlinofchaos commentedThere isn't really a function you can call; the whole thing is bound to the event, which in this case is a click. Anything else would ultimately take more code, so calling $('.class-of-link').trigger('click') is probably the simplest thing you can do.
Comment #2
rvarkonyi commentedOK thanks anyway, closing the issue
Comment #3
rvarkonyi commentedHi merlin,
sorry to reopen... It would be great if you could point me in a direction, obviously I don't expect a fully working solution, but I would appreciate if you could give me some tips in terms of where to start.
Thank you
Rob
Comment #4
merlinofchaos commentedUm. I thought I did?
The complex thing to do would be to modify the ajax object just for that. It's a little complex to do that, though, and requires a lot of understanding of the ajax framework and javascript.
But basically, it works like this. In ajax.js the event is bound like this:
So you COULD just call Drupal.ajax[link_id].eventResponse($('#idoflink').get(0)) rather than triggering the click.
I'm not sure that's actually much better.
Comment #5
rvarkonyi commentedOK, thanks. Closing. Won't reopen I promise