How to exclude in rendering already existing scripts in DOM in Yii2
What method (render or renderAjax etc.) i have to use to exclude rendering one more (the same) jquery, jquery.ui
I have jquery.js on my page. And i (via ajax) load to my page modal window of registration, that requires jquery.js, and it pulls jquery.js second time.
And in the result my page contains 2 jquery.js library. And somewhere starts ocurring errors. I want to fix it by remoeving enother jquery.js
I'm not sure if you are using AssetBundle class but if not - you should.
There is already defined yii\web\JqueryAsset with jquery.js you can use.
Now you can create AssetBundle with your script that will depend on JqueryAsset (read more about assets dependency in the Guide). No matter how many times this asset is registered JqueryAsset will be registered only once.
You can do the same when adding single js file with registerJsFile() - in options array you can use 'depends' key with the JqueryAsset.
Sorry again. I found solution. Here is it
Related
I am working with ReactJS and in a carousel design of Bootstrap, I found this line:
<div class="tns-carousel-inner" data-carousel-options="{"mode": "gallery", "responsive": {"0":{"nav":true, "controls": false},"992":{"nav":false, "controls": true}}}">
I am passing the value of "data-carousel-options" as it is in the above line but it is not working. However, it works fine in plain HTML. I am not sure how I can use this line in ReactJS.
Looks like the problem was not passing the data. The data can be passed exactly in the same way as it is in the question. The problem was, the javascript file which is responsible to act on the provided data needs to be loaded in each page individually. As I was working with React app, I put all the external javascript files (e.g: bootstrap, custom theme js, etc.) in the index.html file inside the "script" tag. But it turns out that not all javascript files work correctly in that way. Sometimes, some javascript files need to be loaded each time the route is changed. So, I had to include the javascript file inside the componentDidMount() and now it works fine.
Here is the link of another question that I asked on how to include external javascript files in ReactJs:
How to make external javascript file work in ReactJs?
I have been working on a personal "how-to" guide, chronicling and keeping a journal of my studies as I go along.
I now have a, almost too long block of code that, when I've encountered this length of code myself, its always frustrating trying to highlight JUST the block without it highlighting the whole page, or not enough.
So, my question is, for rst (reStructuredText) .. code-block::'s, is there an add-on or a way to add in a copy button, for automatic highlighting or automatically adding the text to the users clipboard? Or would this be a more html-literal type of code I'd have to include in the build and reference it in the code block? If so, what would something like that look like as well?
There is a dedicated package for that called sphinx-copybutton.
It's straightforward to use.
# Install
pip install sphinx-copybutton
# Declare it in the conf.py
extensions = [
...
'sphinx_copybutton'
...
]
And that's it, generate the doc and a copy button will appear automatically in each code block.
In Sphinx projects, the presentation of the HTML page is controlled using a template language (Jinja2 by default). So you can make your pages more interactive by adding Javascript to the HTML template file(s) and it will get inserted when Sphinx uses that particular template file to render a page.
Locate your templates directory by searching for templates_path in your conf.py
Jinja templates can extend one another, so you probably want the file that begins with {% extends "basic/layout.html" %}.
Once you track down where in the sequence of extension you want to make your change, you need to combine:
The section of the page where you want this to take effect (typically the main block)
the CSS with a class for code blocks (eg. in mine it's class=highlight). The .CSS file might well be in docs/source/_static/
A javascript snippet to create the button and write to the clipboard (eg. https://clipboardjs.com/)
Next, build the Sphinx project locally (make html) until you have it dialed in and then push your source repo to readthedocs.
Ok, so the title tells very little of my issue.
Basically, I have a project written in node that does something. It's a website that uses express, jade and stylus. I have set up the routing for static content like this:
app.use(express.static('public'));
The website works fine and all the CSS loads properly if, in the HTML, I reference it like this (for example):
link(rel="stylesheet", href="global.css")
As expected, when I hover over the link in Chrome's element viewer, the URL is localhost/global.css
So now I've got a couple of these little project and I want to put them all together. They aren't related but I'd like to put them all on my website. For this I have made a new project that server like a hub for the other ones.
In it, I've setup routing like this:
var proj = require("../proj/server.js");
app.use("/proj ", proj);
and in each of the projects I have set the modules exports like this module.exports = app where app is their respective express app object.
This also worked like a charm. I didn't have to run a separate server instance on a separate port for each project. Instead, you can access them like localhost/proj/
Now here's where the issue starts. The CSS that is referenced in the generated HTML of each project doesn't point to localhost/proj/global.css. Instead it still points to localhost/global.css. And since there's no global.css in the public folder of my hub application, it doesn't find it.
I could, of course, just change the relative URLs to proj/global.css instead of just global.css and this does work, but it means that I need to modify all of my projects. It also means that I have one more string to change should I decide to change their names.
Besides, the URL already shows localhost/proj, so why can't it just be automatically implied that when I reference global.css it should be looked for in localhost/proj/global.css?
I'm sure there's some easy trick I'm missing. Maybe my relative URLs should have some extra stuff that says it refers to the current URL?
Edit:
It actually seems that the relative URLs work, but only if the address in the address bar is localhost/proj/. If it's localhost/proj it doesn't. What can I do to force that last slash?
I don't know if it can help you, but in express, you can define several "public" directories
router.use(express.static(path.resolve(__dirname, 'client')));
router.use(express.static(path.resolve(__dirname, 'public')));
router.use(express.static(path.resolve(__dirname, 'foo')));
I want to use custom css/js. I have moved these to the server. But the drupal page starts with a section. how do I add the custom css/js to my drupal site page. I have admin and just need to know what to do to get this included on the page. Please send exact steps as I am totally new to drupal. Thanks
"Custom CSS and JavaScript files" module allows to specify two folders, one for CSS and one for JS where the stylesheets and javascripts files are located respectively.
The module creates two sub-folders under your files folder:
files/customcssjs/css
files/customcssjs/js
Indeed, it's depend on your task, what css and js files should do, and adding these in custom module (drupal_add_js, drupal_add_css) or custom theme (info file, preprocess in template.php or directly in page-XXX.tpl.php and so on).
I'm trying to include one html file into another. I'm coding on the MAMP stack. I assume SSI's are automatically permitted. I type
<!--#include virtual="header.html" -->
in the body of one html file, the other file is called header.html, and they are both in the same folder. I even tried calling the file header.shtml instead. None of this works. It's frustrating.
The code isn't included. I'm including a form and a navigation bar, but they don't appear.
I assume SSI's are automatically permitted
That's a very big assumption. SSIs will only work if you've got mod_include loaded. You also need to enable the filter for the relevant files, e.g.
AddOutputFilter INCLUDES .shtml
...and of course ensure that Includes are not overridden elsewhere in the config.
Did you read this?