How to add js in view created by interface I want to create a new button control in my ip_geoloc leaflet map. So, i created a view by using the drupal interface -> /admin/structure/views/view/markers_admin/edit

And now i want to set a custom JS wich execute only in this view. I've create a module to create custom form. And my goals are when the user click on the button control in the map, a modal pop with a form with lat/lng field to add dynamically the marker on the map.

I searched everything (how to create a modal -> colorbox, how to create a custom button, how to add the marker...) but i don't know how to attach the javascript to this page.

I've tried to implements these hooks (4th comments) in my custom module but this not work : https://www.drupal.org/node/1993228

Can you help me ?
If you are following that 4th comment exactly the problem is probably that it is a hook for viewing a node, not for a 'view'. Ambiguous to be sure.

The accepted answer here should be helpful: How do I add JavaScript specific for a view?.

EDIT  

Okay, this may be more helpful. The trick here is finding a place to hook in to check to the page before it is rendered to add the javascript to the render array. The assumption this code makes (which may not be accurate) is that you are looking at a views page. If the view is nested in a block or a panels pane this may not work as well.  Here goes:

/**
 * Implements hook_page_alter().
 */
function food_truck_form_page_alter(&amp;$page) {
  $views_page = views_get_page_view();

  if ($views_page-&gt;name == 'marqueurs_admin') {
    $path = drupal_get_path('module', 'food_truck_form' );
    $page['#attached']['js'][] = array(
      'type'=&gt;'file',
      'data' =&gt; $path . 'js/food_truck_form.js'
    );
  }
}


This also assumes that you are implementing it in a module called food_truck_form and your view is named 'marqueurs_admin'.

Also, as a side-note, it often works better formatting-wise to edit your post to add the additional info there rather than in the comments.