Warning: Table './drupal_fandt_old/accesslog' is marked as crashed and last (automatic?) repair failed query: SELECT uid, timestamp FROM accesslog WHERE (path = 'node/142' OR uid > 0) AND sid = '49a8064b079d3c2e989b8febf2a2a093' ORDER BY timestamp DESC LIMIT 0, 1 in /var/www/akishige/fandt/includes/database.mysqli.inc on line 128
Drupal 7 における jQuery | FOREST & trees

Drupal 7 における jQuery

Drupal 7 では jQuery の振る舞いがちょっと Drupal 6 のそれとは異なるようで、少し手こずりました。

まず、通常 Drupal.behaviors で jQuery の全コードを囲むと思いますが、Drupal 6 では


Drupal.behaviors.module_name = function(context) {
  your code goes here...
};

となっていたことと思いますが、Drupal 7 では


Drupal.behaviors.module_name = {
  attache: function(context) {
    your code goes here...
  }
};

という風に変わります(参照:Converthing 6x modules to 7.x - Changed Drupal.behaviors ...

また、通常 jQuery では、以下のように $(ドルサイン)を使ってコマンドを書き始めます。


$(document).ready(function() {
  alert("Hello World");
};

しかし、Drupal 7 に含まれる jQuery では、この $ マークで jQuery コマンドを書き始めるということができないようです。

この問題を解決するには2通りの方法があります。1つ目は、$ の代わりに jQuery という文字列を用いるというものです。


jQuery(document).ready(function() {
  alert("Hello World");
};

もう一つは、以下のように jQuery のコード全体を囲う、というものです。(参考:Converting 6.x modules to 7.x - JavaScript should be compatible with other libraries than jQuery


(function($) {
  $(document).ready(function() {
    alert('Hello World.');
  })
})(jQuery)

以上をまとめると、Drupal 7 向けに jQuery を使うには、以下のようにするのが基本、と言えそうです。(コメント文からした3行は任意に書き換える)


Drupal.behaviors.your_module = {
  attach: function(context) {
    (function($) {
      // your code goes here ...
      $(document).ready(function() {
        alert('Hello World.');
      })
    })(jQuery)
  }
}

Comments

Bidan Eti

cara mengobati apendisitis secara alami on this occasion I will give health information regarding the importance of the requirement of vitamin B1 (thiamine) for the body. cara mengobati apendisitis secara alami and cara mengobati apendisitis secara alami vitamin B1 (thiamine) is not a vitamin that is rare. cara mengobati apendisitis secara alami small number of levels can be found in nearly all foods, and there are plenty of foods rich in vitamin B1. cara mengobati abses otot secara alami cara mengobati abses otot secara alami however expected that the majority of people are deficient in vitamin which is very important. cara mengobati abses otot secara alami cara mengobati abses otot secara alami Why did it happen? The answer is because the vitamin is generally disappears when a food containing vitamin B1 has been processed. Manfaat Calcium Softgel Green World Manfaat Calcium Softgel Green World the vitamin B1 deficiency has been linked to the disease beriberi which can cause death and can also cause a number of symptoms related to the nervous system, including blindness Manfaat Calcium Softgel Green World Manfaat Calcium Softgel Green World.

Reply

vig power capsule Protecting the environment is one of today’s most serious issues. It is not a secret that our planet is in danger! Almost every day we hear about a new problem affecting the environment. vig power capsule This list seems to be endless! The main issues are pollution, acid rain, greenhouse effect, climate change, rainforest destruction, and the extinction of thousands of animal and plant species. We are all aware of these concerns and can admit that we caused them. vig power capsule Most people really care about the future of our planet and realize it is time to improve the situation. otherwise, the environmental issues will become vig power capsule

Zinc tablet Green World

Zinc tablet Green World merupakan produk unggulan Green World yang telah terbukti khasiatnya dan telah teruji untuk menjadi obat penambah nafsu makan secara alami tanpa efek samping. Zinc tablet terbuat dari 100% bahan alami pilihan yang di rekomendasikan oleh para ahli sehingga terjamin khasiatnya.

Business

This is one of the most important blogs that I have seen, keep it up!

The information

goldenslot The information you provide is information that is useful to me, not ever.  

gmail iniciar sesiones un

gmail iniciar sesiones un proceso extremadamente sencillo que no sólo ofrece acceso a la bandeja de entrada de gmail, sino también a otros procesos como YoutubeGoogle+ y Google Play.  

Reply

jelly gamat Apparently a lot of the benefits of Information and Communication Technology in education. With the possible occurrence of education and dissemination of information technology to transform science education sectors harga qnc jelly gamatharga jelly gamat gold g The students who were attending school can be helped by the internet in homework, the students in search of a paper on the internet tasks. With the lessons of Information and Communication Technology in schools, where students can learn and utilize ICT in their daily lives such as harga jelly gamat

The information

goldenslot The information you provide is information that is useful to me, not ever.
    

bokep

Video Bokep Hello very nice website!! Guy ,Excellent, Blog Video Bokep Superb ..I will bookmark your site and take the feeds also? I am glad to search out a lot of useful info here in the post, Bokep Mesum we’d like work out more strategies on this regard, thank you for sharing Video Bokep Indo ,googd your blogs Keluaran Togel

Nice Article

Nice Article :)

Written Telly Updates

best ways to bring latest technology into the classroom. Great work keep it up and write some more technology updates also. I read your blog regularly. Telly Written Updates

Obat Herbal Pendarahan Rahim

Obat Herbal Pendarahan Rahim

Telly Serial Updates

All Indian TV Serials are now cover by tellyserialupdates.com website, you can read the full episode written update from this blog. Our website will provide you latest serial gossips news, recap and precap of all upcoming episodes of 2016. written updates. Apparently a lot of the benefits of Information and Communication Technology in education. With the possible occurrence of education and dissemination of information technology to transform science education

This is really nice one to read

حيث تقوم جميع الفتيات الصغار

حيث تقوم جميع الفتيات الصغار بإختيار الكثير من الملابس المختلفة من أجل أن تتنقل باربي مع صاحبتها إلى عالم الخيال حيث السهرات والحفلات, وأيضا التنزه بين الحدائق, ولا يمكن أن تخلو خزانة باربي من ملابس يومية مخملية مدهشة وأنيقة العاب بنات , وقد قام مبتكروا الألعاب بتخصيص أحد العاب الفتيات الخاصة بشخصية باربي من أجل إختيار الملابس اليومية الخاصة بها من خلال لعبة تلبيس باربي المخملية.

juegos de pokemon

 Excellent article.<a href="http://www.juegoscazarpokemon.com/">juegos de pokemon</a>

juegos de pokemon

 Excellent article.http://www.frutijuegos.com/

When I visit this site I see

When I visit this site I see this site is popular and a lot of traffic. I want to learn to make my site as it is. obat amandel | obat cacar air | obat batu ginjal

Written Telly Updates

i like your theme can you please tell me the name of your theme because i want to use your theme on my blog also.you can read the full episode written update from this blog. Our website will provide you latest serial gossips news, recap and precap of all upcoming episodes of 2016. Check More here Shakti Written Updates

I would like to install

I would like to install Drupal 7 in some of my sites. Crazy Bulk reviews

Indian TV Serial Written Updates

well now you will get latest trending news of all daily soaps and we will provide you days by day written updates of all episodes. So now you will get all information at a single spot so please follow this link Kumkum Bhagya Written Updates

My son was very uncomfortable

My son was very uncomfortable because of the same problem then we started taking guidance by them and now he feels much relaxed than ever before! vpn service review

I have mentioned problem of

I have mentioned problem of Jquery in Drupal couple of time but no response so far from any developer.click this link

obat sperma

bragas calvin klein

Clean grill well bragas calvin klein before cooking and oil the grates generously to prevent sticking.

There are some

There are some interesting points in time in this article but I don’t know if I see all of them center to heart. There is some validity but I will take hold opinion until I look into it further. Good article , thanks and we want more! Added to FeedBurner as well Berita Bola Prediksi Bola Information

Magnificent website.

Magnificent website. Plenty isabel marant chaussures of helpful info here. I am sending it to several friends ans additionally new balance femme bordeaux sharing in delicious. And naturally, thanks in your sweat!

You should take

You should take part in a contest for one of the best blogs on the web. I will recommend this site! Culbutage.com Diabeq.com Star-glasses.com

If we can only encounter each

If we can only encounter each other rather than stay with each other 192.168.1.1|192.168.1.1|192.168.1.1|192.168.1.1

FB Remarketing 2.0 Biz in a

use ful news

very nice.100% Job Oriented R Programming Training In Chennai for more Information click to  <a href="http://www.greenstechnologys.com/dot-net-course-content.html">the best dot-net training in Chennai</a>

xender for pc

Very use full  and interesting <a href=http://www.xenderforpcapp.com>xender for pc </a>

awesome site

wow such a good site thanks happy dussehra 2016

glad to be acquainted with

glad to be acquainted with you , <a href="http://narwhale-io.com/">game Narwhale-io</a>

Black Magic Specialist Baba

Really Nice Post Thanks For Share.  Black Magic Specialist

Happy New Year 2017

Watch NFL games

Watch NFL Games - You can watch live nfl games 2016 for free online - including the playoffs without paying a huge cable bill every month. NFL Live streaming

An impressive share, I just

An impressive share, I just given this onto a colleague who was doing a little analysis on this. And he in fact bought me breakfast because I found it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love reading more on this topic. If possible, as you become expertise, would you mind updating your blog with more details? It is highly helpful for me. Big thumb up for this blog post! Website Information Visit

This is highly informatics.

This is highly informatics. crisp and clear. I think that everything has been described in systematic manner so that reader could get maximum information and learn many things Explaindio 3.0 ReviewI was searching for Explaindio 3.0 Review

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.