E
E
evil0o2014-07-20 23:19:46
Drupal
evil0o, 2014-07-20 23:19:46

How to call from onClick() function in jQuery space?

How to run details() from onClick?

Drupal CMS is therefore "(function ($) { })(jQuery);"

<a onClick="details(11)"> Подробнее</a>
<script>
(function ($) {
function details(id){
 $('#nameID'+id).dialog("open");
}
})(jQuery);
</script>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
andead, 2014-07-21
@evil0o

Outside the closure - no way.
Drupal has a global object for this Drupal. Example:

(function ($) {
  Drupal.mymodule = Drupal.mymodule || {
    details: function (id) {
      $('#nameID'+id).dialog("open");
    }
  };
})(jQuery);

Call like this:
Drupal.mymodule.details(...);

B
barkalov, 2014-07-20
@barkalov

Either hook the onClick event with a script inside the closure, or declare the details function in global visibility.

S
Sergey Melnikov, 2014-07-21
@mlnkv

hang events via onclick - a crutch solution, hang an event inside a closure

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question