This is a beginner question. Can you explain how to add the sample code you provide in the readme file that uses the drupal_add_js? I tried to add this in my theme's template.php file but it didn't work. Any help would be greatly appreciated.

Comments

arcane’s picture

I'd like to use this in the profile fields. I think I can do a hook form alter and add the code that way..

arcane’s picture

I performed a hook form alter in my module and added the following code:

   if ($form_id == 'profile_node_form' && $form_state['submitted'] == FALSE) {
        if (module_exists('jquery_freebase')) {
                jq_add('freebase');
                drupal_add_js(drupal_get_path('module', 'custom') . '/custom.js');
        }
   }

In my custom.js file I have:

Drupal.behaviors.custom = function(context) {
   $('#edit-field-profile-artist-0-value').freebaseSuggest( {ac_param:{type:'/music/artist'}} );
   $('#edit-track').freebaseSuggest( {ac_param:{type:'/music/track'}} );
}

When I debug the page in firebug and go to the javascript console I get the error:

$("#edit-field-profile-artist-0-value").freebaseSuggest is not a function
 $('#edit-field-profile-artist-0-value'...st( {ac_param:{type:'/music/artist'}} );

I am not sure why I am getting the above error. I see in my source listing that /sites/all/modules/jquery_freebase/jquery.freebase.suggest/dist/freebase.suggest.js?a is being included

Can you provide any advice I might try?

arcane’s picture

Actually the above code is working. I checked on a different computer and it seems to work fine now.

toemaz’s picture

Status: Active » Postponed (maintainer needs more info)

Can I presume this issue is fixed? If so, feel free to put the issue Status on closed or fixed.

toemaz’s picture

Status: Postponed (maintainer needs more info) » Fixed

Status: Fixed » Closed (fixed)

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