How can I add jquery functionality to a popup form created by the popups module?
I'm trying to add an jquery character counter to the form. This works fine until I try it inside a popup.
In the header of the page de .js files are loaded, but cannot be reached from the popup.
Is there a co-drupaller that knows how to solve this?

Comments

ellishettinga’s picture

Title: additional.js loads in page, but not in popup, how to reach javascript in popup » solution
Status: Active » Fixed

Thank you Hans Idink for helpin me out!!
Read this:
http://api.drupal.org/api/drupal/developer--topics--javascript_startup_g...

instead of this:

$(document).ready(function(){
$(":text").css({background:"red"}).after('

120 characters left

').keyup(updateCount);
});

use this

Drupal.behaviors.modulenameBehavior = function (context) {
$(":text").css({background:"red"}).after('

120 characters left

').keyup(updateCount);
};

problem solved!

RedTop’s picture

Could you please elaborate on that. I'm not a coder, so the obvious is not so obvious to me. :P

I would like to use this BUEditor button code inside a popup:

php:
$L = drupal_to_js(_smileys_list());
$P = base_path();
drupal_add_js("(function($){
var click = function() {
  BUE.active.replaceSelection(this.firstChild.alt, 'end');
  return false;
};
var map = function(s) {
return $('<a href=\"#\" title=\"'+ s.description +'\"><img src=\"$P'+ s.image +'\" alt=\" '+ s.acronyms.split(' ')[0] +' \" /></a>').css('margin', '0.5em').click(click)[0];
};
var links = $.map($L, map);
BUE.smlyWrap = function() {
  return $('<div style=\"width:200px\"></div>').append(links);
};
})(jQuery);", 'inline');
return 'js: E.quickPop.open(BUE.smlyWrap());';

Could I use your solution? Do you know what I need to change for this to work?

Status: Fixed » Closed (fixed)
Issue tags: -JavaScript, -popups

Automatically closed -- issue fixed for 2 weeks with no activity.