I'm trying to associate a button with a dynamic url with the following javascript: &lt;script type=&quot;text/javascript&quot;&gt;     var name = {{pp.name}};     var url = &quot;{% url 'editproject' %}&quot;;     document.getElementById(&quot;myButton&quot;).onclick = function () {      location.href = url + &quot;/&quot; + name    }; &lt;/script&gt;   But I am getting an error when I try to click on the button. pp.name is a django variable that would return the name of the project, and the url I'm trying to access is path('editproject/&lt;str:name&gt;/', p.update, name=&quot;editproject&quot;),
34431
When I render a page using the Django template renderer, I can pass in a dictionary variable containing various values to manipulate them in the page using {{ myVar }}.  Is there a way to access the same variable in Javascript (perhaps using the DOM, I don't know how Django makes the variables accessible)? I want to be able to lookup details using an AJAX lookup based on the values contained in the variables passed in.
63684
I need to set the text within a DIV element dynamically. What is the best, browser safe approach? I have prototypejs and scriptaculous available.  &lt;div id="panel"&gt;   &lt;div id="field_name"&gt;TEXT GOES HERE&lt;/div&gt; &lt;/div&gt;   Here's what the function will look like:  function showPanel(fieldName) {   var fieldNameElement = document.getElementById('field_name');   //Make replacement here }
34708
In SharePoint how do you get the ID value from the url of the page you are on using javascript( Jquery,ajax, Rest..),  e.g. I have the url like so: http:// ddd/mypage?ID=xx   I tried before to retrieve the full url but it didn't get the ID and its value. so I have to get the ID value directly with the get method
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?
66978
I have got a problem with JavaScript. I want to add a drop down list control with a link as Value of it. After it will be choosen and clicked button it schould redirect me to chosen link. I tried this code from this Article:       &lt;select name="list" id="list" accesskey="target"&gt;     &lt;option value='none' selected&gt;Choose a theme&lt;/option&gt;     &lt;option value="index.html"&gt;Theme 1&lt;/option&gt;     &lt;option value="theme2.html"&gt;Theme 2&lt;/option&gt;     &lt;option value="theme3.html"&gt;Theme 3&lt;/option&gt; &lt;select&gt; &lt;input type=button value="Go" onclick="goToNewPage()" /&gt;  &lt;script type="text/javascript"&gt; function goToNewPage() {     var url = document.getElementById('list').value;     if(url != 'none') {         window.location = url;     } }     but when I tried to add by the script, or by html on site, or by designer its erase me that sort of text:  &lt;input type=button value="Go" onclick="goToNewPage()" /&gt;   It's live only:  &lt;input type=button value="Go" /&gt;
10610
I have a url like   I need a javascript function to give me the 'th' value from that.  All my urls have the same format (2 letter filenames, with .html extension).  I want it to be a safe function, so if someone passes in an empty url it doesn't break.  I know how to check for length, but I should be checking for null to right?
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']);
35183
I'm pulling items out of the DOM with jQuery and want to set a property on an object using the id of the DOM element.   Example  const obj = {}  jQuery(itemsFromDom).each(function() {   const element = jQuery(this)   const name = element.attr('id')   const value = element.attr('value')    // Here is the problem   obj.name = value })   If itemsFromDom includes an element with an id of "myId", I want obj to have a property named "myId". The above gives me name.  How do I name a property of an object using a variable using JavaScript?
26387
I have a text file in the root of my web app  and I'd like to load it into a variable in javascript.. in groovy I would do this:  def fileContents = 'http://localhost/foo.txt'.toURL().text; println fileContents;   How can I get a similar result in javascript?
59918
I know lightning doesn't support javascript buttons. I know there are alternative routes to do this with actions, lightning components, and visualforce. I'm asking how to do something that according to my research is supported but doesn't seem to work.  From the      Custom buttons and links that define their content source as URL are   now supported in Lightning Experience and the Salesforce1 mobile app.   This feature was previously available in Salesforce Classic only.   Seems straight forward. Create the button, add it to the classic page layout, see it in lightning. But for the life of me, I can't figure out how to get this thing to show up.  Here's the custom button, pretty basic   I've got it setup as the only button on the page layout, it's the assigned layout when I edit the page in lightning.   But in lightning I'm getting nothing   What am I doing wrong? Seems like I'm following the instructions outlined in this . Even though it's in the release notes, it's not mentioned in the . Other peopler have had  and have gotten it working eventually. What am I missing? Are there other factors to consider? Are those documented anywhere?
13132
How can I create a shortcut for URL in my desktop? I want to use them in Firefox or Chrome.   If a copy and paste didn't work.   What script I have to use?
120233
I would like to be able to pass aarguments to operators that I am calling from panels/buttons but I do not know how to do that. At the moment I use "global" variables but they tend to make the code a bit like a puzzle since I need to constantly update them.  See the code below, in that example I would like to pass an argument (like ARG) to "object.simple_operator" when the button is clicked.  import bpy     def DO_SOMETHING(arg):      print(arg)  return  class SimpleOperator(bpy.types.Operator):     """Tooltip"""     bl_idname = "object.simple_operator"     bl_label = "Simple Object Operator"      @classmethod     def poll(cls, context):         return context.active_object is not None      def execute(self, context):         DO_SOMETHING(ARG)         return {'FINISHED'}    class MyPanel(bpy.types.Panel):      bl_label = "mypanel"     bl_idname = "OBJECT_PT_MyPanel"      def draw(self, context):          layout = self.layout          wm = context.window_manager          obj = context.object          row = layout.row()         row.operator('object.simple_operator')
88408
I have this Visualforce code snippet in a page:  &lt;apex:outputLink value="javascript:if (window.confirm('Are you sure?')) DeleteQuoteLineItem('{!LineItem.QuoteLineItem.Id}');"&gt;     Del &lt;/apex:outputLink&gt;  &lt;apex:actionFunction action="{!DeleteQuoteLineItem}" name="DeleteQuoteLineItem" reRender="content"&gt;     &lt;apex:param value="test"/&gt; &lt;/apex:actionFunction&gt;   The two methods I'm using for testing are:  public void DeleteQuoteLineItem(String RecordID) {     System.debug('method with a paramater');     System.debug(RecordID); }  public void DeleteQuoteLineItem() {     System.debug('method without a parameter'); }   Everytime I click on the link to execute the apex:actionFunction, it's calling the DeleteQuoteLineItem() method without any parameter. I looked online and it seems like I need to create a class attribute and use assignTo= in my apex:param to populate it accordingly.  Is it possible to prevent this behavior and use standard method parameters, so I don't have to create class attributes? I want to work on a clean and optimized codebase, preventing unnecessary variable scope (so no class attribute when it's not required) and improve code re-usability by staying context agnostic.  Thanks
64578
I added a get_absolute_url function to one of my models.  def get_absolute_url(self):     return '/foo/bar'    The admin site picks it up and adds a "view on site" link to the detail page for that object (when I put a real URL there instead of "/foo/bar").  The problem is instead of going to http://localhost:8000/foo/bar, it goes to http://example.com/foo/bar.  What am I doing wrong?
114745
I am trying to Preview and download document from LWC, From apex controller i am returning Map&lt;> contains ID and Document name, and iteration that map data in html file and passing map.key value to href url, but dynamic is not populating in URL.    &lt;template for:each={mapData} for:item="mapkey"&gt;                            Test: {mapkey.key}                                                         &lt;lightning-button-icon key={mapkey} icon-name="utility:download"  variant="bare" alternative-text="Settings"&gt;&lt;/lightning-button-icon&gt;                                &lt;a key={mapkey} style="color: #000000"  href ="/sfc/servlet.shepherd/document/download/{mapkey.Key}?operationContext=S1" target="_blank" preview= "{mapkey.value}"&gt;{mapkey.value}&lt;/a&gt;                          &lt;/template&gt;    JS Code:      .then(data =&gt; {            /// var conts = data;                   console.log('data map---&gt;'+data);     if(data){     // eslint-disable-next-line guard-for-in     for(let key in data) {    this.mapData.push({value: data[key], key:key}); //Here we are creating the array to show on UI.    }       } })   Apex Code:   @auraenabled /* Method will return a Map Contains Document ID and Name */ public static Map&lt;string,string&gt; getUrls( string searchstr){     Map&lt;string,string&gt; contdocidandtitle = new Map&lt;string,string&gt;();     system.debug('searchstr'+searchstr);             For(Document cd :[select id,folderid,name from document where folder.name =:searchstr]){         contdocidandtitle.put(cd.id,cd.name);                 }     return contdocidandtitle; }   Error is: sfc/servlet.shepherd/document/download/%7Bmapkey.Key%7D?operationContext=S1 in URL "mapkey.key" priniting instead of ID Help me with valuable suggestions.
61223
I want to dynamically add new forms to a Django formset, so that when the user clicks an &quot;add&quot; button it runs JavaScript that adds a new form (which is part of the formset) to the page.
112471
On my team, we usually do string concatentation like this:  var url = // some dynamically generated URL var sb = new StringBuffer(); sb.append("&lt;a href='").append(url).append("'&gt;click here&lt;/a&gt;");   Obviously the following is much more readable:  var url = // some dynamically generated URL var sb = "&lt;a href='" + url + "'&gt;click here&lt;/a&gt;";   But the JS experts claim that the + operator is less performant than StringBuffer.append(). Is this really true?