In Astro.js, when i put these lines in a .astro file :
<link rel="stylesheet" href={ Astro.resolve('../styles/preloader.scss') }>
<link rel="stylesheet" href={ Astro.resolve('../styles/application.scss') } media="print" onload="this.onload=null;this.media='all'">
the result I get at build time is this :
(I am building a multi language site. The 'en' in en.ffae6e3d.css is from the english page /en )
<link rel="stylesheet" href="../assets/application.ddd2d855.css">
<link rel="stylesheet" href="../assets/en.ffae6e3d.css">
How can I get this result ?
<link rel="stylesheet" href="../assets/preloader.css">
<link rel="stylesheet" href="../assets/application.css" media="print" onload="this.onload=null;this.media='all'">
This is the (expected) result I get indevelop mode.
You could try is:inline for loading resource files on the client side without compiling it during build.
https://docs.astro.build/en/reference/directives-reference/#isinline
Related
i'm making a form with bootstrap, when I open my HTML file from the folder I have the following error and the styles are not loading error
But when I use Live Server in Visual Studio Code to open the HTML there is all Oklive server
Why is it happen and how can I solve it? here is my code:
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="/practica bootstrap-copia/css/bootstrap.min.css">
<link rel="stylesheet" href="/practica bootstrap-copia/form.css">
<link href="https://fonts.googleapis.com/css2?family=Bodoni+Moda:wght#400;800&display=swap" rel="stylesheet">
<title>Arma tu cv</title>
<!-- BOOTSTRAP AND JS -->
<script src="/practica bootstrap-copia/js/bootstrap.min.js"></script>
<script src="/scripts.js"></script>
my folders
Thanks for your attention.
I reproduced your problem and found the solution. Remove your leading forward slashes in your hrefs. They need to be relative directory positions, not absolute.
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="practica bootstrap-copia/css/bootstrap.min.css">
<link rel="stylesheet" href="practica bootstrap-copia/form.css">
<link href="https://fonts.googleapis.com/css2?family=Bodoni+Moda:wght#400;800&display=swap" rel="stylesheet">
<title>Arma tu cv</title>
I noticed earlier that when I added parameters to my routes, this broke my views as it seemed to change the links to my CSS and JS files. After hours of trying to get the HTML package working in Laravel 5.1, I finally gave up and threw in the towel due to Composer issues.
I opted to just take the simple route and go back to linking them directly, however I am now struggling to get even this to work.
<link type="text/css" rel="stylesheet" href="{{ public_path() }}/assets/css/bootstrap.min.css">
<link type="text/css" rel="stylesheet" href="{{ public_path() }}/assets/css/metismenu.min.css">
<link type="text/css" rel="stylesheet" href="{{ public_path() }}/assets/css/sb-admin-2.css">
<link type="text/css" rel="stylesheet" href="{{ public_path() }}/assets/css/font-awesome.min.css">
<link type="text/css" rel="stylesheet" href="{{ public_path() }}/assets/css/datatables.bootstrap.css">
<link type="text/css" rel="stylesheet" href="{{ public_path() }}/assets/css/datatables.responsive.css">
Rather than linking to the local file, its appending the entire string to my base URL and trying to link to that which is obviously wrong.
Current Link:
http://domain.com/home/roster/laravel/public/assets/css/bootstrap.min.css
Correct Link:
http://domain.com/assets/css/bootstrap.min.css
Just linking to "/assets/css/bootstrap.min.css" works fine until I add Route parameters. What can I do to get these links working short of hard coding the entire URL?
Try this one
<link href="<?php echo URL::asset('css/app.css'); ?>" rel="stylesheet" type="text/css">
I believe this will fix your problem
Another solution:
<link type="text/css" rel="stylesheet" href="{{ URL::to('/') }}/assets/css/bootstrap.min.css">
Very rare. I am working with L5.1 and looks good together with HTML package. Just to keep in mind. Require the following package:
"illuminate/html": "~5.0#dev"
Then run composer update. After the package is installed, edit config/app.php adding the provider:
'Illuminate\Html\HtmlServiceProvider',
And facade:
'HTML' => 'Illuminate\Html\HtmlFacade'
Now, lets see some solutions to show your assets links:
Using html facade
{!! HTML::style('assets/css/bootstrap.min.css') !!}
Using raw code calling url() function:
<link type="text/css" rel="stylesheet" href="{{ url('assets/css/bootstrap.min.css') }}">
Using raw code calling URL facade:
<link type="text/css" rel="stylesheet" href="{{ URL::to('assets/css/bootstrap.min.css') }}">
As a note, do not use public_path() because it returns an absolute directory path like /var/www/html/laravel instead an url.
I am using MVC4 with Razor.
Here is my css and java script files code
<link rel="stylesheet" href="~/Content/kendo/kendo.common.min.css" type="text/css" >
<link rel="stylesheet" href="~/Content/kendo/kendo.rtl.min.css" type="text/css" >
<link rel="stylesheet" href="~/Content/kendo/kendo.default.min.css" type="text/css" >
<link rel="stylesheet" href="~/Content/kendo/kendo.dataviz.min.css" type="text/css" >
<link rel="stylesheet" href="~/Content/kendo/kendo.dataviz.default.min.css" type="text/css" >
<link rel="stylesheet" href="~/Content/kendo/kendo.mobile.all.min.css" type="text/css" >
<script src="#Url.Content("~/Scripts/kendo/jquery-1.9.1.min.js")"></script>
<script src="#Url.Content("~/Scripts/kendo/jszip.min.js")"></script>
but the problem is when I call kendo.all.min.js from live url mean when I add this url
<script src="http://cdn.kendostatic.com/2014.3.1119/js/kendo.all.min.js"></script>
then my grid sucessfully exported to excel but if I use this url
<script src="#Url.Content("~/Scripts/kendo/kendo.all.min.js")"></script>
then upon exporting nothing happens and one more thing that kendo.all.min.js file in the project is same as in live url.
Kindly help.
Its solved!
At my end its not working while debugging but when I deployed on my local server then it started working there.
I'm relatively new to web programming so I used a couple of templates to create my website, all of them related to Twitter Bootstrap.
My login page correctly shows Bootstrap modals. These are the imports I used there:
<link rel="stylesheet" href="css/bootstrap.css" />
<link rel="stylesheet" href="css/bootstrap-responsive.css" />
<link rel="stylesheet" href="css/custom.css" />
<link type="text/css" rel="stylesheet" href="stylesheet.css" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="js/bootstrap.js"></script>
The problems start with the main page after login. It was taken from another template and it uses the following imports:
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"/>
<link rel="stylesheet" href="css/custom.css" />
<link rel="stylesheet" type="text/css" href="css/dashboard2.css"/>
<link type="text/css" rel="stylesheet" href="stylesheet.css" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="js/bootstrap.js"></script>
As you can see the only change is the source of Bootstrap. In the first case I downloaded it to the css folder, while in the second case it's taken directly from the server.
As a result the modals do not show in the main page (the second one). The screen fades to black but no modal is shown.
If I modify the imports of the main page to take Bootstrap from the css folder instead of the server, the modals do show, but the layout of the whole page is ruined:
<link rel="stylesheet" href="css/bootstrap.css" />
<link rel="stylesheet" href="css/bootstrap-responsive.css" />
<link rel="stylesheet" href="css/custom.css" />
<link rel="stylesheet" type="text/css" href="css/dashboard2.css"/>
<link type="text/css" rel="stylesheet" href="stylesheet.css" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="js/bootstrap.js"></script>
Instead of this:
Any ideas?
Have you add meta tag for responsive in head tag of the page. If not then try to add following meta tag into your head tags of the page.
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
Hope this will be resolve your problem.
Note : First try this to add into your version in which you imports bootstrap downloaded files.
Ok after some research I solved my problem, I hope others will benefit from it.
This post actually solved it: here
Apparently the syntax for the modal in Bootstrap 3 is different and among other things it has to include these lines:
<div class="modal-dialog">
<div class="modal-content">
So I took the example under the link, tweaked it for my purposes and it worked. Problem solved.
I'm trying to use the slider() function of jQuery UI, and keep getting the following error in the console:
TypeError: undefined is not a function (evaluating jQuery('#slider').slider())
I've definitely linked to the jQuery UI javascript and CSS files correctly - when I view the page source, they're all there. Why am I still getting this error?
If it's of any use, I'm using Rails and also some Bootstrap stuff. Here's the javascript code:
<script type="text/javascript">
$(document).ready(function(){
$('#slider').slider();
});
</script>
Thanks
Here's the <head>:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="../../docs-assets/ico/favicon.png">
<link href="/assets/jquery.ui.core.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/jquery.ui.theme.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/jquery.ui.accordion.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/jquery.ui.menu.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/jquery.ui.autocomplete.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/jquery.ui.button.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/jquery.ui.datepicker.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/jquery.ui.resizable.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/jquery.ui.dialog.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/jquery.ui.progressbar.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/jquery.ui.selectable.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/jquery.ui.slider.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/jquery.ui.spinner.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/jquery.ui.tabs.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/jquery.ui.tooltip.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/jquery.ui.base.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/jquery.ui.all.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/application.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/bootstrap-theme.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/bootstrap-theme.min.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/bootstrap.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/bootstrap.min.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/companies.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/jquery-ui.min.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/scaffolds.css?body=1" media="screen" rel="stylesheet" />
<link href="/assets/bootstrap.css?body=1" media="screen" rel="stylesheet" />
<script src="/assets/jquery.js?body=1"></script>
<script src="/assets/jquery_ujs.js?body=1"></script>
<script src="/assets/bootstrap.js?body=1"></script>
<script src="/assets/bootstrap.min.js?body=1"></script>
<script src="/assets/companies.js?body=1"></script>
<script src="/assets/jquery-1.11.0.min.js?body=1"></script>
<script src="/assets/jquery-ui.min.js?body=1"></script>
<script src="/assets/application.js?body=1"></script>
<title>New Company - OE Fort by Oxford Entrepreneurs</title>
<meta content="authenticity_token" name="csrf-param" />
<meta content="FcOEJfo8vcCzR+Dq+5zOVSvm7Npfo+R+FoXrEPpV3js=" name="csrf-token" />
<!-- Bootstrap core CSS -->
<link href="../../../app/assets/stylesheets/bootstrap.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js" type="text/javascript"></script>
<link href="../../../app/assets/stylesheets/jquery-ui.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="../../jumbotron.css" rel="stylesheet">
<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" />
<!-- Just for debugging purposes. Don't actually copy this line! -->
<!--[if lt IE 9]><script src="../../docs-assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
<link href='http://fonts.googleapis.com/css?family=Oswald:400,700' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,400,600,300' rel='stylesheet' type='text/css'>
<script type="text/javascript">
jQuery(document).ready(function(){
$('#slider').slider();
});
</script>
</head>
I would surmise the error would be caused by loading this function before JQuery is loaded yet (hence why you're seeing the undefined error -- JQuery is undefined)
Can you detail the way you're loading the code? Can you post your <head> tag?
The possible causes could be:
JQuery is not loaded
JQueryUI is not loaded
$("#slider") is not a valid element
The error is related to a missing line in your application.js.coffee file. As mentioned here: https://github.com/joliss/jquery-ui-rails you can require special modules here.
So just add the following line to your application.js.coffee file and it should work:
#= require jquery.ui.slider
Another possible cause, I've just discovered, is when you have two different versions of jquery linked.
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
... (some other bundles), and then:
bundles.Add(new ScriptBundle("~/bundles/ajax").Include(
"~/Scripts/jquery-1.10.2.min.js",
"~/Scripts/jquery.unobtrusive-ajax.min.js"));
E.g. in my jqueryui bundle, I had jquery-1.10.4.min.js (or rather, the latest version), but in my ajax bundle I had jquery-1.10.2.min.js. Double clicking on the error in Chrome element inspector, revealed links to code in 1.10.2. When I changed that to 1.10.4 in the ajax bundle, the jqueryui element suddenly worked (in my case it was Tabs).
What I should have done, of course, is just leave everything at jquery-{version}.js.
So in summary, a(n overlooked) version conflict is another possible cause for this error.
I know that this will not answer this exact question but it may help others getting the same error message for the slider() function.
If you have preset the value in the slider when initialising it, you could have something like the following:
$('#slider').val(5).slider();
if you remove the value (5), you also get the “TypeError: 'undefined' is not a function”
ie.
$('#slider').val().slider();
instead you would need to insert the starting value into the input tag.
<input type="text" id="slider" value="5">
You may have this kind of setup if the slider is used in many places in your site and you want to have your js file contain the default rather than having each slider contain the same information. In my case I needed to decentralise the value and it caused the error seen here.
In case anyone else runs into this, I had trouble getting selectable to work with asp.net
Turns out I wasn't properly including everything, but this gentleman made it dummy proof:
http://blog.falafel.com/three-steps-use-jquery-ui-asp-net-mvc-5/
try this if you are facing "uncaught typeerror is not a function javascript"
It works
jQuery(function($) {
// your code here
});