Using bounds_changed on a map

Here is an example demonstrating the use of 'bounds_changed' in javascript.
It assumes your map id is 'key_1', that you have a page identifier class 'view-display-id-page'
and that 'show maplinks' is enabled in the view. Any markers that fall outside the viewport will be hidden in the list of links.
Edit 'mytheme_script' to whatever suits your needs.

JavaScript Libraries

JavaScript libraries are registered by modules implementing hook_library().

Entity JS

Entity JS allows for Javascript layer access to some commonly used entity-related functions such as EntityFieldQuery.

This is achieved through Drupal menu callbacks and jQuery $.ajax calls.

Note: jQuery's jqXHR Object uses the .done() method that requires later versions of jQuery (1.5+) than what currently ships with Drupal 7. In order to use these examples, we recommend installing jQuery Update. For more on .done(), review the .promise() method jQuery API docs.

entity_create

Create an entity by providing a type and an array of arguments. Shown printing response below.

values = {
    "name": "username", 
    "mail": "username@example.com",
}
entity_create('user', values).done(function(data) { console.log(data); });

Uses a $.post callback URL: /entity_create/[entity_type]

entity_render_view

Return a rendered entity using a view mode. Shown printing HTML to console below.

entity_render_view('node', 1, 'default').done(function(data) { console.log(data); });
Uses a $.get callback URL: /entity_js_drupal_render_entity_view/[entity_type]/[entity_id]/[view_mode]

Pass the theme path to javascript

Description

This extends Drupal.settings allowing you to get the theme path in a javascript file

Steps

Add a preprocess function to your theme's template.php

Using drupal_add_js we extend Drupal.settings in order to make it a variable that returns the path to the theme

p.s. don't copy the php tags into template.php just what's inside.

Pass the theme path to javascript

Description

This extends Drupal.settings allowing you to get the theme path in a javascript file

Steps

Add a preprocess function to your theme's template.php
Using drupal_add_js we extend Drupal.settings in order to make it a variable that returns the path to the theme

p.s. don't copy the php tags into template.php just what's inside.

Peekaboo; Ajax field formatter

The Peekaboo module is designed to allow a field's full formatted value to not be calculated and output during a page load of the node, but to be pulled in through a separate request.

Pages

Subscribe with RSS Subscribe to RSS - javascript