In my code for drupal 6 I had added the following js, jquery-ui and css files   jquery_ui_add('ui.draggable');   drupal_add_css(drupal_get_path('module', 'ort') . '/js/jquery.alerts.css');   drupal_add_js(drupal_get_path('module', 'ort') . '/js/jquery.alerts.js');   drupal_add_js(drupal_get_path('module', 'ort') . '/js/ort.js');   For drupal 7 I have to write the above code.. I have read that drupal 7 has jquery ui as part of core so how should add the  jquery_ui_add('ui.draggable'); //drupal 6   code given above in drupal 7 ?
121223
Im using Drupal 7, which ships with jQuery UI. I need to have  Accordion only on the homepage. jQuery will not just let me download Accordion and then use drupal_add_js().    Do you have any suggestion?
6322
I'm using Drupal v7.22 and whenever I try to Modify the Display on views, and press the 'Add and configure' button on adding a field, or any button that sends data to the server, the page reloads and I just get a long JSON String returned in Chrome, or IE will try to download the return...  Sometimes it'll accept my change, but more often than not, it won't.  It was doing this on 7.21 and then I updated to 7.22 and it stopped for a day or two, now it's doing it again.  I am extremely new to Drupal, but I am a quick learner and most things are going smoothly.  What did I break and how can I fix it?
73555
I am currently trying to write javascript within a script editor to hide the 'View Properties' and 'Edit Properties' items in the ECB.  I have found many solutions that edit the core.js file. However, that is not preferable for me as there are multiple sites adn this is not for every site and every library. Eventually this will be applied to a certain library but right now I would just like this to work in general before I worry about that.  I have tried removing the item when the menu is loaded using the below javascript. Where #mp6_0_3 is the id of the 'Edit Properties' menu item.  &lt;script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"&gt; &lt;/script&gt;   &lt;script language="javascript" type="text/javascript"&gt;  $(document).ready(function() {     $('.ms-core-menu-list').live('mouseover', function() {         $('#mp6_0_3').parent().hide();         $('#mp6_0_3').remove();            }); }); &lt;/script&gt;
38677
I usually store my JavaScript/jQuery files in the Site Assets library, but I see on forums that others are using the Style Library.  What are the respective benefits of each?
92799
Several of my pages use both JQuery and Protoype. Since I upgraded to version 1.3 of JQuery this appears to be causing problems, because both libraries define a function named '$'.  JQuery provides a function noConflict() which relinquishes control of $ to other libraries that may be using it. So it seems like I need to go through all my pages that look like this:  &lt;head&gt;           &lt;script type="text/javascript" src="/obp/js/prototype.js"&gt;&lt;/script&gt;     &lt;script type="text/javascript" src="/obp/js/jquery.js"&gt;&lt;/script&gt; &lt;/head&gt;   and change them to look like this:  &lt;head&gt;           &lt;script type="text/javascript" src="/obp/js/prototype.js"&gt;&lt;/script&gt;     &lt;script type="text/javascript" src="/obp/js/jquery.js"&gt;&lt;/script&gt;     &lt;script type="text/javascript"&gt;         jQuery.noConflict();         var $j = jQuery;     &lt;/script&gt; &lt;/head&gt;   I should then be able to use '$' for Prototype and '$j' (or 'jQuery') for JQuery. I'm not entirely happy about duplicating these 2 lines of code in every relevant page, and expect that at some point somebody is likely to forget to add them to a new page. I'd prefer to be able to do the following    Create a file jquery-noconflict.js which "includes" jquery.js and the 2 lines of code shown above Import jquery-noconflict.js (instead of jquery.js) in all my JSP/HTML pages   However, I'm not sure if it's possible to include one JS file in another, in the manner I've described? Of course an alternate solution is simply to add the 2 lines of code above to jquery.js directly, but if I do that I'll need to remember to do it every time I upgrade JQuery.
91117
I'm looking for a good approach to manipulate some JS code from within a module call. (Using Drupal 6.)  I have a set of JavaScript functions I need to add to a page. (Regular JavaScript, no jQuery.) Unfortunately they rely on some variables from the page they are shown on. So my current approach is to generate all the JavaScript from within PHP code which results in a whole lot of escaped strings like $output .= '  var url = "'. $url . '";' . "\n";, which is not so nice after 20-30 lines of code.  So I would like to move all the JavaScript code into it's own .js file, and find a way to inject my variables. So far, the only solution I could come up with is putting it in a temporary file, read that, modify and save it to the /files directory. But is there another, more preferred way?
47319
In my applications, I often have to use relative paths. For example, when I reference JQuery, I usually do so like this:  &lt;script type="text/javascript" src="../Scripts/jquery-1.2.6.js"&gt;&lt;/script&gt;   Now that I'm making the transition to MVC, I need to account for the different paths a page might have, relative to the root. This was of course an issue with URL rewriting in the past, but I managed to work around it by using consistent paths.  I'm aware that the standard solution is to use absolute paths such as:  &lt;script type="text/javascript" src="/Scripts/jquery-1.2.6.js"&gt;&lt;/script&gt;   but this will not work for me as during the development cycle, I have to deploy to a test machine on which the app will run in a virtual directory. Root relative paths don't work when the root changes. Also, for maintenance reasons, I cannot simply change out all the paths for the duration of deploying the test - that would be a nightmare in itself.  So what's the best solution?  Edit:  Since this question is still receiving views and answers, I thought it might be prudent to update it to note that as of Razor V2, support for root-relative urls is baked in, so you can use   &lt;img src="~/Content/MyImage.jpg"&gt;   without any server-side syntax, and the view engine automatically replaces ~/ with whatever the current site root is.
70318
I am trying to set particular javascript files for a specific node page by getting the path alias. like this:  $path=drupal_get_path_alias();   if($path == 'about-us')   drupal_add_js(drupal_get_path('theme', 'mytheme') . "/page-download.js");   which it doesnt work.  But when i add the particular javascript file to my .info file it works.  Also in other pages i will have to unset some of the javascript files if the above does not work but still unsetting javascripts does not work.   unset($vars['js']['all']['page-download.js']);
69421
I am trying to add this script (Marc Anderson's blog) to AllItems.aspx.  Please guide me where it needs to go and what needs to be done to make it work.  Thank you.  &lt;script language="javascript" type="text/javascript" src="../../jQuery%20Libraries/jquery-1.4.2.min.js"&gt;&lt;/script&gt; &lt;script language="javascript" type="text/javascript" src="../../jQuery%20Libraries/jquery.SPServices-0.5.4.min.js"&gt;&lt;/script&gt; &lt;script language="javascript" type="text/javascript"&gt; $(document).ready(function() {     var userDepartment = $().SPServices.SPGetCurrentUser({         fieldName: "Department"     });     $("input[Title='Department']").val(userDepartment); var userPhone = $().SPServices.SPGetCurrentUser({     fieldName: "WorkPhone" }); $("input[Title='Phone']").val(userPhone); }); &lt;/script&gt;
38061
I know that I can use the following function to remove the version from all .css and .js files:  add_filter( 'style_loader_src', 'sdt_remove_ver_css_js', 9999 ); add_filter( 'script_loader_src', 'sdt_remove_ver_css_js', 9999 ); function sdt_remove_ver_css_js( $src ) {     if ( strpos( $src, 'ver=' ) )         $src = remove_query_arg( 'ver', $src );     return $src; }   But I have some files, for instance style.css, in the case of which I want to add a version in the following way:  function css_versioning() {     wp_enqueue_style( 'style',         get_stylesheet_directory_uri() . '/style.css' ,         false,         filemtime( get_stylesheet_directory() . '/style.css' ),         'all' ); }   But the previous function removes also this version. So the question is how to make the two work together?
23806
I've been using Drupal for several years, but only just dipping a toe in with Drush - I've bought an ebook tutorial and working my way through. I've installed Composer, and used it to install Drush. The tutorial book specified a particular build of Drush to install (7.0.0-alpha5). I've navigated to a drupal folder and run   drush st    to get installation info which works fine. The tutorial explains that you don't have to navigate into the drupal folder to do this, instead using  drush --root=PATH-TO-DRUPAL-SITE st   however this brings an error:   Fatal error: Call to undefined function conf_path()   Googling this error suggests this a problem with the version of Drush and to upgrade.  SO I've navigated into the .composer/vendor/drush/drush folder and run      composer global update but composer says nothing to update, confirming the version as 7.0.0-alpha5 - I assume this is not the latest 7.x version, so do I need something changing in the composer.json file?
10878
I add js file with drupal_add_js in hook_form_alter, it is ok and I see it in list of js loaded in page, but when I submit form and form not validate and return to that form (after validation failed) I don't see js files that added to form, why this happened? and how can add my js file in that form after validation failed ?   some part of my code   function mymodle_form_alter(&amp;$form, $form_state, $form_id) {   if ($form_id == 'news_node_form') {     drupal_add_js(drupal_get_path('module', 'mymodule') . '/js/mymodulejsfile.js'); //, array('scope' =&gt; 'footer','weight' =&gt; 10));   } }   code work correctly in add and edit form, but when form submit and validation failed it show validation error but my js file not loaded in page (I checked html source and check firebug script files), but there is not my js file,
52621
I have designed a website on Drupal. It was working fine but now when I tried to update a link (by adding any name under any option) it does not show the rich text editor. Instead it shows the plain html body.  This way :  &lt;ul&gt; Assignemnt UID &lt;/ul&gt;   I mean switch to plain text editor is not working. This way I am not able to update any file or link.  How I can make this to work?    I am still stuck with the same problem. CKeditor does not work, instead the plain text editor gets opened. I tried everything from re-installing CKeditor to updating Drupal to newer version. When I open any heading and try to open the edit option, it runs very slow. Then when it gets open the data is visible in the form of plain text(no CKeditor). I checked the console it shows this error:     Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience in drupal   Any help?
80378
I'm cleaning up my big crazy style sheets (possibly pertinent to a future question) and I'm wondering the best way to add custom CSS to a specific node or page. In particular, my work site's home page is a Panel Page and it has a bunch of different styling. Right now the CSS is just included with the main theme style sheet. Is there a way to say, &quot;if this is node Foo, then add foo.css&quot;? Is  what I'm looking for? I might be interested in generalizing this to other nodes/sections/etc, but at the moment I just want to handle this one item.
13250
In your MODULENAME.module file: $testVariable = 'himanshu'; drupal_add_js(array('MODULENAME' =&gt; array('testvar' =&gt; $testVariable)), array('type' =&gt; 'setting')); drupal_add_js(drupal_get_path('module', 'MODULENAME') . '/MODULENAME.js');  In MODULENAME.js file: (function($) {   Drupal.behaviors.MODULENAME = {     attach: function (context, settings) {       alert(settings.MODULENAME.testvar);     }   }; })(jQuery);  this way you can pass your php variable in drupal javascript file and use the variable :) How can I implement the above in Drupal 8?
64792
In Drupal 7, if we wanted to push code to our environments enabling modules, we would call  in hook_update_N(). We no longer have that in Drupal 8, so how do we programmatically enable modules? Do we use Drupal 8's Configuration Manager or hook_update_N()?  A diff on the exported configuration yields this:  +++ b/cim/sync/core.extension.yml @@ -10,6 +10,9 @@ module:    config: 0    contact: 0    contextual: 0 +  ctools: 0   So it seems the module is enabled via code using Configuration Manager. We're also working with the idea of this:  function mymodule_update_8003() {   $modules = array(     'ctools',   );   \Drupal::service('module_installer')-&gt;install($modules); }   What is the correct method?
26508
I have an SP2013 wiki page that I want to use a jQuery accordion on.  Just with some static content, not pulling any information from anywhere in SharePoint.  I created the page, inserted a script editor web part at the top, and inserted this snippet:  &lt;script src="//code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt; &lt;script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"&gt;&lt;/script&gt; &lt;script&gt;     $(function () {         $("#accordion").accordion({collapsible: true, active: false, icons:false });     }); &lt;/script&gt;   Then, I put the cursor under the script editor web part, and clicked on "Edit Source".  Then underneath the HTML that represents the script editor, I put this HTML (basically the jQuery accordion demo HTML):  &lt;div id="accordion"&gt;    &lt;h3&gt;       Section 1    &lt;/h3&gt;    &lt;div&gt;       &lt;p&gt;Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate.&lt;/p&gt;    &lt;/div&gt;    &lt;h3&gt;       Section 2    &lt;/h3&gt;    &lt;div&gt;       &lt;p&gt;Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In suscipit faucibus urna.&lt;/p&gt;    &lt;/div&gt;    &lt;h3&gt;       Section 3    &lt;/h3&gt;    &lt;div&gt;       &lt;p&gt;Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis. Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.&lt;/p&gt;    &lt;/div&gt;    &lt;h3&gt;       Section 4    &lt;/h3&gt;    &lt;div&gt;       &lt;p&gt;Cras dictum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia mauris vel est.&lt;/p&gt;       &lt;p&gt;Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.&lt;/p&gt;    &lt;/div&gt; &lt;/div&gt;   After I saved the page, the accordion collapsed initially (as it is supposed to), but clicking on any of the headers does not expand the section.  If I go back into edit mode for the page, it works as expected - clicking a header expands the section.  Save it again, and it stops working.  What am I missing?  I don't think what I'm trying to do is all that complicated...  EDIT 12/8: Ok, so I put the jQuery and jQuery UI scripts in the site's Site Assets folder, and the behavior is the same -- the scripts do not get loaded in IE or Firefox unless the page is in Edit mode.  Incidentally I think the other script snippet, where I hook up the accordion, is also not getting loaded unless the page is in edit mode.  The reason I think this is that I changed the way I referenced the main jQuery script (to something that didn't work), and the debugger halted on $(function () { ...., saying $ was undefined.  So if jQuery is not loaded, and the debugger thinks $ is undefined, at least it's hitting that section of code.  Which makes me think that in non-edit mode, not only is jQuery not getting loaded, but that section of script is not getting loaded either, because the debugger is not choking on $.  Can anyone provide any insight as to why the Script Editor web part seems to be not working in IE and Firefox?  (Because apparently in Chrome it works fine.)