I am having two problems when opening a new popup:

#1 When i open a new popup to edit a node (edit/node/111) if the content type contains a data popup widget, i got an error "$(this).datepicker is not a function"

# When i have some functions from jquery ui (draggable / sortable) applyed into a list on a page and i click in a popup link on the page, after closing the popup window i am not able to use again jquery ui defined functions correctly. I keep receiving "sortable is not defined".

I have tried different strategies but i am unable to suceed. Any advices?

Thanks

Hernani

Comments

wanjee’s picture

Hi,

Exact same issue for me.

I have a page with several important Javascript functionnalities. I also have a link on which popups_add_popups(...) has been used. Everything works fine until I open the popup. The popup opens and closes as it should but once closes I get errors with other functionnalities. Just like Hernani I keep receiving "foobar... is not defined" error message. In fact it looks like some of the libraries I use are not loaded anymore as soon as the popup as been opened ?

Why are my libraries unloaded ?
Any solution to fix this behaviour ?

Thanks,

Wanjee

wanjee’s picture

Component: Miscellaneous » Code
wanjee’s picture

The js files loaded by addJS function (in popups.js) do not include some of the files I use for other functionnalities.

So I think the flow is :

1. Main page loads all the required javascript (and my_file.js)
2. Popup opens and loads "some" javascript files including jquery.js (but not my_file.js). In the meantime all the functions I bound to jQuery (using jQuery.fn.my_func = function(){...} ) in my_file.js are not bound anymore to jQuery.
3. From this point every call to $('#item').my_func(); will lead to the error "$('#item').my_func(); is not a function"

My guess is that the files loaded at point number 2 are the one of the called page (the one inside the popup) as it works when I add my_file.js to the called page using drupal_add_js()...

I really don't want to include all the javascript file from the calling page into any potential called one so... is there a better solution ?

wanjee’s picture

Does nobody have any idea about this problem? :(

rc2020’s picture

I can also confirm this problem.

catorghans’s picture

I see 2 possible solutions, but my Jquery knowledge is not good enough for building a proper patch.

-1 might be to use http://drupal.org/project/ajax_load (thanks to http://drupal.org/node/675922)
-2 to make use of the event "popups_open_path_done" which is triggered in popups.js after a popup is displayed, but I don't know how.

cbosco’s picture

How to use the "popups_open_path_done" event:

$(document).bind('popups_open_path_done', function() {
  ... script to call when event fires ...
});
operations’s picture

Hi,
thank you cbosco & catorghans for the workaround ! I had a tooltip js not working on popups dialog, and fixed it using the popups_open_path_done binding :)

sjeandroz’s picture

Hi,

where must we write this code?

How to use the "popups_open_path_done" event:

$(document).bind('popups_open_path_done', function() {
... script to call when event fires ...
});

In any js file who is loaded in the page before the popup is called?

operations’s picture

Hi @sjeandroz,

Here is what I did:

  1. I added a new js file for tooltips in my custom module folder
  2. I added the following code for the tooltips to work on both pages and popups:
    $(document).ready(function() {
    	$('a.user_tooltip').each(function(i) {
    		$(this).simpletip({
    			content: $(this).find('.tooltip_html').html(),
    			fixed: false
    		});
    	});
    });
    
    // This is where you put the binding fix
    $(document).bind('popups_open_path_done', function() {
      $('a.user_tooltip').each(function(i) {
            $(this).simpletip({
                    content: $(this).find('.tooltip_html').html(),
                    fixed: false
            });
      });
    });

Hope this helps ..

-- Mohannad

kenorb’s picture

Marked as duplicated of this: #462754: datepicker is not a function

kenorb’s picture

Title: Jquery in popups » Popups: $(this).datepicker is not a function
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.