How do I use a Bundle in Laravel like Asp MVC?
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/js").Include(
"~/Scripts/js/jquery/jquery-2.1.3.min.js",
"~/Scripts/js/jqueryui/jquery-ui-1.10.3.min.js",
"~/Scripts/js/AdminLTE/app.min.js",
"~/Scripts/js/bootstrap/bootstrap.min.js",
"~/Scripts/js/iframePopUp.js",
"~/Scripts/js/sweetalert/sweet-alert.min.js"
));
}
Laravel 5.1 comes with Elixir http://laravel.com/docs/5.0/elixir. Which can do this for you see sections
Combine Stylesheets
elixir(function(mix) {
mix.styles([
"normalize.css",
"main.css"
]);
});
and Combine Scripts
elixir(function(mix) {
mix.scripts([
"jquery.js",
"app.js"
]);
});
Here is a pretty neat free laracast video that can help you with this too ->
https://laracasts.com/series/whats-new-in-laravel-5/episodes/10
Related
I'm trying to implement Fresco in my NS Vue app.
I have this in my main.js
Vue.registerElement('FrescoDrawee', () => require("nativescript-fresco").FrescoDrawee)
var application = require("application");
var fresco = require("nativescript-fresco");
if (application.android) {
application.onLaunch = function (intent) {
fresco.initialize();
};
}
and in home.vue
< FrescoDrawee horizontalAlignment="stretch" height="150" :imageUri="item.avatar" />
this is the error I'm getting. "SimpleDraweeView was not initialized!". I'm pretty sure the way I'm initializing it is wrong. Googling it gives me examples in TS and Angular, and none for nativescript Vue. any help would be greatly appreciated
Mostly TypeScript is again JavaScript if you eliminate the typings from code. It's just the same you will have to follow in irrespective of your flavour (Core / Angular / Vue).
if (application.android) {
application.on("launch", function () {
fresco.initialize();
});
}
Source: https://github.com/NativeScript/nativescript-fresco#how-to-use-nativescript-fresco
With the last version of Laravel, I cannot use a simple jQuery plugin.
I try to use bootstrap-datepicker plugin. So I used:
yarn add bootstrap-datepicker
Then, in my app.js:
import './bootstrap';
import 'bootstrap-datepicker';
In bootstrap.js, I have:
try {
window.$ = window.jQuery = require('jquery');
require('bootstrap');
} catch (e) {}
This should make jQuery global I guess.
But when I try:
$(function() {
$('.input-daterange input').each(function() {
$(this).datepicker('clearDates');
});
});
I got the error:
app.js:41747 Uncaught TypeError: $(...).datepicker is not a function
I have this error with a lot of plugins (daterangepicker, datepicker...)
What I have to do to use Webpack / Mix to just use one simple jQuery plugin?
I made it this way:
In console:
npm i jquery-ui-dist
/resources/assets/js/bootstrap.js:
try {
window.$ = window.jQuery = require('jquery');
require('bootstrap');
require('jquery-ui-dist/jquery-ui')
} catch (e) {}
/resources/assets/sass/app.scss:
#import'~jquery-ui-dist/jquery-ui';
In your blade or at the end of boostrap.js
$('.input-daterange input').datepicker(params)
In this case I'm usign jQuery UI DatePicker
If jQuery and jQuery Plugin not in the same file, you need to use $.fn.extend() merge the contents of plugin object onto the jQuery prototype to provide new jQuery instance methods.
$.fn.extend({
datepicker: function() {
require('bootstrap-datepicker');
}
});
I found the way to implement listeners for components in EXTJS MVC. But I cannot find the way to add listeners for grid plugins at controller.
not sure if it can help you, I my self now use ComponentQuery directly to retrieve currently edited field.. check it..
ExtJS 4 - How to listen event of each field within roweditor inside controller
The below example worked for me. That is to say, I can now handle plugin events in my controller. Since I was developing a custom plugin and you are using a packaged plugin, your approach will be a little different. I think you should extend the plugin that you want to use, adding the "mixins" and "relayEvents" concepts from my example. You could also create an override for the plugin you are using.
Ext.define( "Ext.ux.MyController", {
extend: "Ext.app.Controller",
init: function() {
this.control( {
"mycomponentxtype": {
"load": function(){ ... },
"unload": function(){ ... }
}
} )
}
} );
Ext.define( "Ext.ux.MyPlugin", {
extend: "Ext.AbstractPlugin",
alias: "plugin.myplugin",
mixins: [
"Ext.util.Observable"
],
config: {
...
},
init: function( myComponent ) {
var me = this;
// contruction of the mixin is required.
me.mixins["Ext.util.Observable"].constructor.call( me );
myComponent.relayEvents( me, [ "load", "unload" ] );
.
.
.
}
} );
Even though the original question is from early 2013. I came to this post in mid-2014 in search of an adequate answer and did not find it. This is essentially how I solved my problem. I hope it helps!
This has been answered, though specifically for rowEditing plugin, it should be applicable to any plugin:
Ext JS 4 - How to control rowEditor inside controller
My website is generating some content dynamically, so I have to somehow launch the highlight.js plugin again after loading it.
This code is used to launch the highlighter:
hljs.initHighlightingOnLoad();
I tried to do something like hljs.initHighlighting(); to do this again but it does not work.
You must set called to false first:
hljs.initHighlighting.called = false;
hljs.initHighlighting();
You can reinitialize all of the codeblocks like this.
$(document).ready(function() {
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
});
or if you have a div with an ID of myBlock, you can do this.
$(document).ready(function() {
$('#myBlock').each(function(i, e) {hljs.highlightBlock(e)});
});
i hope this could solve your problem..
you have to use
hljs.highlightAll()
since, hljs.initHighlightingOnLoad() is deprecated since version 10.6.
if you're using react, you could apply at componentdidMount..
useEffect(() => {
hljs.highlightAll()
}, []);
or, if another framework, please call that function when page loaded.
more: https://highlightjs.readthedocs.io/en/latest/api.html
I am using rails 3.1 and I am facing a problem with attaching codemirror editor to my form textarea.
//----- code (application.js)------//
$(document).ready(function() {
$('#comment_body').each(function() {
var editor = CodeMirror.fromTextArea(this, {
lineNumbers : true,
matchBrackets : true
});
})
})
//------end------//
The problem is that the textarea becomes uneditable. Can you tell me the way to use this?
You have to add the scripts and the css of codemirror in your application.js for the scripts and application.css for the stylesheets.
application.js should have this:
//=require codemirror
And your application.css should have:
/*
*= require codemirror
*/