On some popups there is Javascript error:

$form.ajaxForm is not a function in popups.js?E (line 934)
--
openPathContent()("add/parent", "Parent Registration", "<form action="/add/parent?&amp;destination=node%2Fadd%2Fchild" accept-charset="UTF-8" 
...
</form>\n", a.popups-reference-0 parent?des.../add/child, Object updateMethod=none updateSource=initial, null)

Any clue why this happen?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kenorb’s picture

And when after close this Popup, cursor have loading icon.

slip’s picture

I had the same problem. Seems to be related to jquery.js being included twice.

In the Popups.addJS = function(js) in popups.js commenting out the following block gets rid of the error but could possibly cause other prolbems? Anyways, I'm reverting back to stable popups.

for (var i in scripts) {
var src = scripts[i];
if (!$('script[src='+ src + ']').length && !Popups.addedJS[src]) {
// Get the script from the server and execute it.
$.ajax({
type: 'GET',
url: src,
dataType: 'script',
async : false,
success: function(script) {
eval(script);
}
});
alert(src);
// Mark the js as added to the underlying page.
Popups.addedJS[src] = true;
}
}

JaceRider’s picture

Hey guys,

I believe I figured out what is going on here -- and the jquery_update module is at fault. I haven't delved into it very deeply, but jquery_update doesn't do it's thing until after the popups api has checked to see if jquery.js exists. So, on your initial page you have the jquery.js file being placed in there by jquery_update -- and on the newly loaded page called by popup api, you have the default jquery.js.

Popup api sees them as being different files (since they are in different places), and whalaaa, you have two version of jquery being loaded.

Hope this helps.

slip’s picture

I can't find the jquery twice in the source. Also popups 1.3 works.

sethcohn’s picture

I did a quick hack, checking src for the jquery string, and skipping if so, and that works great.


for (var i in scripts) {
var src = scripts[i];
if (src.match('/misc/jquery.js')) {
Popups.addedJS[src] = true;
}
if (!$('script[src='+ src + ']').length && !Popups.addedJS[src]) {

DeFr’s picture

Title: $form.ajaxForm is not a function » Compatibility with jQuery Update ($form.ajaxForm is not a function)
Status: Active » Needs review
FileSize
1.34 KB

In fact, it's a general compatibility with how jQuery Update alters the javascript files loaded, and the fact that Popups2 loads the missing JS files on demand: Popups sees the original path instead of the altered ones, and thus loads the original versions. This is obviously problematic with jquery.js, but with the dev version of jQuery Update that needs to also change ahah.js, its an even bigger problem.

It's solved in D7 with the shinny drupal_alter('js') added in #315801: JavaScript Patch #3: JS Alter Operation , but for D6 I would propose to check in popups_get_js if the jquery_update module exists, and if it does, use the replacements it defines.

One issue with this approach is that jquery_update_get_replacements returns the list of all the files it replaces except jquery.js. Attached patch deals with this problem by simply removing misc/jquery.js from the list of files that needs to be loaded. The rationale is that by the time we get in popups_get_js, we're inside a popup, which means that we've already used jQuery to open the popup and thus its already loaded.

DeFr’s picture

Category: support » feature

Bumping this issue to a feature request, as it's not really a support request anymore.

hefox’s picture

The patch is working for me =)

starbow’s picture

Status: Needs review » Reviewed & tested by the community

Ok, so we have a community thumbs up. Giving the patch a quick eyeball, it looks good. I will roll this into the next 2.x release

tayzlor’s picture

patch in #6 did not completely fix the issue for me. Whilst it did not re-load the jqyery.js file, it added a bunch of other javascript files (both from my theme) + it reloaded the entire popups.js file again. This cause the popups to behave weirdly and basically screw up =)

DeFr’s picture

@tayzlor: Just to be sure, those other js files are added both with and without the patch in #6 ? If so, are you doing something alike to jQuery Update in your theme, altering the path to the javascript files in a preprocess_page hook ?

I guess an easy check would be the following one: are the full path to the popups.js normally loaded on the page, and the one Popups tries to add to the page when you open a popup the same ?

tayzlor’s picture

@DeFr

without the patch in #6 , the extra js files are not loaded (a couple are, jquery.js , jquery_form.js) , with the patch, it does not load jquery.js again anymore, but it loads around 6 others, including popups.js again, which appears to break the popup stack.

I'm also not altering any paths to any js files in any preprocess functions, that im aware of.

DeFr’s picture

@tayzlor: Another stab in the dark: do you have JavaScript files optimization turned on in admin/settings/performance ?

alextronic’s picture

The patch is not working for me. I have jQuery Update enabled, applied the patch, but anything jQuery into the popup just doesn't work (jcarousel, tabs, validation, slimbox, etc). Nothing. I have JavaScript files optimization turned OFF, but changing this does not impact on anything at all.

alextronic’s picture

I have also tried the hacks above, and nothing. Please can anyone tell me why nothing jQuey is working inside the popups and how to solve this?... The patch was no use to me.

I tried reverting to the last stable version but it was all the same. These are my loaded scripts/libraries:

<script type="text/javascript" src="/<?php print path_to_theme(); ?>/js/jcarousel/lib/thickbox/thickbox.js"></script>
<script type="text/javascript" src="/<?php print path_to_theme(); ?>/js/jcarousel/lib/jquery.jcarousel.pack.js"></script>
<script type="text/javascript" src="/<?php print path_to_theme(); ?>/js/jcarousel/lib/jquery.jcarousel.js"></script>
<script type="text/javascript" src="/<?php print path_to_theme(); ?>/js/tabs/jquery.history_remote.pack.js"></script>
<script type="text/javascript" src="/<?php print path_to_theme(); ?>/js/tabs/jquery.tabs.js"></script>
<script type="text/javascript" src="/<?php print path_to_theme(); ?>/js/tabs/jquery.tabs.min.js"></script>
<script type="text/javascript" src="/<?php print path_to_theme(); ?>/js/tabs/jquery.tabs.pack.js"></script>
<script type="text/javascript" src="/<?php print path_to_theme(); ?>/js/validator/js/jquery.validationEngine.js"></script>
<script type="text/javascript" src="/<?php print path_to_theme(); ?>/js/slimbox/js/slimbox2.js"></script>

Thanks!!!

DeFr’s picture

@alextronic: Javascript autoloading isn't implemented in the 1.x branch of popups, so unless the page calling the popups contains all the script needed by the popup, it won't work. This is fixed in the unstable 2.x branch of popups, which adds to the calling page all the scripts normally added to the popup page via drupal_add_js.

The patch attached to this issue fix one well identified potential issue when both jQuery Update and Popups are enabled on the same patch. If the JavaScript works in the popup with the stock 2.0-alpha5 release when you disable the JQuery Update module, and doesn't work when you both apply this patch and enable the jQuery Update module, then that's a problem with this patch. Otherwise, it's another issue entirely.

Looking at the code snippet you've posted, it looks like you're putting the javascript files directly in your theme page.tpl.php file, which isn't really supported by the popups approach that suppose the different JS files are added via drupal_add_js. It shouldn't be a complete showstopper at first sight though, because if you did put them in your page.tpl.php file, then they are loaded in the parent window...

(Btw, the correct value for the Javascript files optimisation is OFF for the autodetection of already loaded script to work, so your original setting shouldn't be the problem).

So to sum it up: disable the jQuery Update module, revert to the official 2.0-alpha5 release and check if it works.

  • If it does, and you really need an enabled jQuery Update, then re-apply this patch, re-enable jQuery Update, and check your javascript error message log.
  • If it doesn't, search for another issue that match your problem, or open a new one
alextronic’s picture

"Disable the jQuery Update module, revert to the official 2.0-alpha5 release and check if it works" <- This worked, thanks.

I had to load the validation script from the node, but it worked in the end.

Now I'll try applying the patch and re-enabling jQuery Update.

Thank you

zerolab’s picture

Based on #5,

I added the following couple of lines and it works:

Popups.addJS = function(js) {
...
...

  for (var i in scripts) {
    var src = scripts[i];

    if (!jQuery.browser.mozilla && (isNaN(i) || src.match(/misc\/jquery.js/) || src.match(/popups.js/) || src.match(/misc\/drupal.js/)  || src.match(/misc\/gmap.js/) ) )
      continue;

without !jQuery.browser.mozilla, jQuery tends to become unresponsive and crashes Firefox. This also solves the popups not showing under Safari/Chrome for me.

That, with the patch from #362878-11: jQuery 1.3.2 issue.

drewish’s picture

Here's what we'd been using.

drewish’s picture

Status: Reviewed & tested by the community » Fixed
FileSize
1.67 KB

Actually had skipped a call to theme('page') where jquery_update does its JS manipulation. Committed the attached to DRUPAL-6--2.

DeFr’s picture

I'm confused by the call to theme('page'). I guess the goal is to trigger jQuery Update preprocess page ? The thing is, we can't really use it (and that's why the second hunk is still needed), because it all goes back straight to $vars['scripts'] as a big pile of

tags, and is then rendered into the page, where it's not that easy to extract and is totally ignored by the patch ? (The confusion also comes from the fact that we've been using the patch in #6 in production for 1+ year, without problem, and it doesn't call theme('page') :-)) Finally, now that the module is maintained again, I've got a few more patches to send your way ;-)
drewish’s picture

Status: Fixed » Active

Humm... maybe you're right about the theme('page') not being needed for jQuery Update but I used that hook as a place to set the list of JS and CSS files for Drupal settings. So I guess we need to update the comment and not blame jquery_update, or move the part where I'm building the active stuff into popups_render_as_json().

tomvolek’s picture

drewish , et. all.
I still see this problem with popups not working if jquery_update is installed.
I am using the latest popups 6.x.2.x-dev and once I disable the jquery_update things work.
This is not acceptable to me as I need to use the jquery_update for alot of other things.
Is there any solution i can do the make poups module to co exist with jquery_update ?

Thanks
Tom

Azol’s picture

The only way that worked for me was providing Popups module with the jQuery library it was designed to work with:

1) copy misc/jquery.form.js file from your Drupal install into sites/all/modules/popups directory;
2) replace

    drupal_add_js('misc/jquery.form.js');

with

    drupal_add_js(drupal_get_path('module', 'popups') .'/jquery.form.js');

in popups.module file.

Not a very elegant solution, but it works and allows me to continue using jQuery Update module as well. If Popups works only with particular jQuery version, we have to pre-pack one with the module itself.

igor.ro’s picture

Replace for jquery update was commented and unset was not.
That is why jquery update module integration was wrong.

Here is the patch

igor.ro’s picture

Sorry previous patch was bugged.
Here is correct one.

llillf’s picture

Hi Igor,

Your patch works perfectly! Thanks first!

But have you noticed that after applying the patch, all the submission get a "Bad Response form submission" message after submit, no matter if the submission is correct or not? Could you give me a little hint why that happens and how to solve it?

Thanks a lot!!!!!!!!!!!!!!1

igor.ro’s picture

I do not think that your problem related to my patch.

Could you roll it back and test again?

kenorb’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Version 6.x is no longer supported due to Drupal 6 End of Life.