Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Tạo file example_block.js bỏ trong thư mục của bạn.
- Ở file example_block.module của bạn thêm vào hook_init để tải file js:
- <?php
- function example_block_init() {
- drupal_add_js(drupal_get_path('module', 'example_block') . '/example_block.js', 'module', 'header');
- }
- ?>
- -------------------------------------------------- Content file .js
- (function ($) {
- Drupal.behaviors.exampleModule = function (context) {
- // Chặn sự kiện submit
- $('form#example_block_form').submit(function () {
- // Kiểm tra trạng thái của textfield, nếu đang ẩn thì cho hiện ra và ngược lại
- var textBox = $(this).children('input[type="text"]');
- if (textBox.is(':hidden')) {
- // Đang ẩn, hiện ra lại cho nhập liệu
- textBox.show().focus();
- } else {
- textBox.hide();
- // Hiện ra dòng chữ
- // ....
- }
- return false;
- });
- }
- })(jQuery);
- Link tham khão (https://groups.drupal.org/node/66868)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement