How to disable AJAX in a Rails app using JQueryMobile - ruby-on-rails-3

I've built a Rails 3 app and I'm trying to get it working with JQueryMobile. I've gone ahead and required query_mobile_rails and that works just fine, but I need to disable the AJAX loading as it seems to get in the way of many things. Looking at the jquerymobile docs, they recommend adding the following javascript after loading JQuery, but before loading JQueryMobile:
$(document).bind("mobileinit", function(){
$.mobile.ajaxEnabled = false;
});
I've been reading through the docs on the Asset Pipeline, but I cannot figure out how I can manage to get my code (the above) inserted after JQuery and before JQueryMobile. Where do I place such a .js file so that it will be loaded at the proper time?
Any help would be greatly appreciated!

Nevermind. I got it. I created a file called app/assets/app_lib.js with the code above and then added a require app_lib between require jquery and require query.mobile in my application.js file.

Related

IHP - Morphdom interfering with other JavaScript (e.g. DyGraph)

I am using IHP and IHP's use of Morphdom and / or Turbolinks seems to interfere with some other JavaScript things when the page isn't a fresh load. This includes things like Elm apps, and in this example, Dygraph:
Uncaught ReferenceError: Dygraph is not defined
at HTMLDivElement.<anonymous> (<anonymous>:51:33)
at Function.each (jquery-3.6.0.slim.min.js:2:3209)
at E.fn.init.each (jquery-3.6.0.slim.min.js:2:1687)
at HTMLDocument.initCharts (<anonymous>:40:25)
at HTMLDocument.dispatch (jquery-3.6.0.slim.min.js:2:42842)
at HTMLDocument.v.handle (jquery-3.6.0.slim.min.js:2:40826)
at Object.e.dispatch (turbolinks.js:5:1411)
at r.notifyApplicationAfterPageLoad (turbolinks.js:6:1175)
at r.visitCompleted (turbolinks.js:6:1800)
at r.complete (turbolinks.js:5:24022)
In this case I am setting up a graph using Dygraph and using the following to try to initiate it upon the Turbolinks loading in:
$(document).on('ready turbolinks:load', initCharts);
which I thought would fix this because it would call the function only when Turbolinks had loaded the page. But this doesn't seem to have helped.
Essentially it seems like the Dygraph js is not loaded before it is called later in the page. This only seems to happen when we come from another page using Morphdom. The temporary fix is to refresh the page when the graphs won't load, but this is definitely not a great long-term solution.
How can I properly load in new JS files in IHP without Morphdom getting in the way? How might we fix such things?

Yii with Bootstrap error (CWebApplication.bootstrap not defined)

I have followed this setup, but not work for me http://www.cniska.net/yii-bootstrap/setup.html, all CSS files do not give style to the page,
So searching I found this thread How to install bootstrap extension in yii using some tricks. But not work's too.
Now I have this error
'Property "CWebApplication.bootstrap" is not defined.'
Anyone can help or have any idea?
Thanks in advance and for my English.
Property "CWebApplication.bootstrap" is not defined.
The error means the system is trying to access Yii::app()->bootstrap, which could be a property on the application. Since bootstrap is a component it should be accessible, if the configuration is done properly.
This error is most likely because you forgot the following in the main config file:
'components'=>array(
'bootstrap'=>array(
'class'=>'bootstrap.components.Bootstrap',
),
),
// This should point to the location you placed the files in for example extensions/bootstrap/components/bootstrap.php
The class location above will only work if the alias is set properly before setting the configuration.
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');
Instead you could also change "bootstrap.components.Bootstrap" into "application.extensions.bootstrap.components.bootstrap".
I strongly advise you to use Yiistrap, it was made by the person who create yii boostrap and the person who created Yiibooster. Yiistrap has everything from both extensions and more new stuff. here is the page http://www.getyiistrap.com , also has a fully documented API which yii boostrap do not have and it will save a lot of google searches.

Ajax Doc Cart for virtuemart not working

mod_ajax_dock cart Not working in which come following error.
this.load undefined or can not Cannot read property 'style'.
so plz help me solve this question
That's generally a Javascript conflict caused by the various scripts that your site is loading. The first place to start is to install jQuery Easy to strip out multiple instances of jQuery as well as the usually loaded Mootools. You will have to mess around with the settings, I usually have it strip everything out and see what breaks, then start adding scripts back in until everything works.
http://extensions.joomla.org/extensions/core-enhancements/performance/jquery-scripts/18327

JQuery date picker + Rails 3.1. integration

I know how to use jquery alone but since I am pretty new to Rails 3.1 I have only little idea how to integrate jquery into Rails.
So far I have come up with following steps but the first (naive) way of programing things are usually wrong :-)
datepicker plugin for jquery (e.g. jquery-ui-timepicker-addon.js) into app/assets/javascripts
add line //= jquery-ui-timepicker-addon to application.js
When I want date picker in some VIEW I will create app/assets/javascripts/VIEW.js and in there I will use standard jQuery to hook up date picker
Is there a more elegant way?
You can try this:
Add the jquery-ui .js file to the app/javascripts folder. Which you can download [here][1]
[1]: http://jqueryui.com/download. Maybe your jquery-ui-timepicker-addon.js will do as well.
You don't need to add code to application.js. As all .js files in the javascripts folder
will be included and compiled automatically
Add the following line to
app/javascripts/{viewname}.js.coffee
$ -> $('.date').datepicker()
The line above is the coffeescript equivalent of:
$("#datepicker").datepicker();

how begin with appcelerator for desktop (and use the API's)

I've a bit experience with qt+ and creating not so complex web pages, but I don't know how begin with titanium...when I run the default app this work...I can change the index.html like a web page...I can include javascript code and jquery too...very nice...but when I try run api functions I don't know how include these...all examples talk about iphone and a app.js file...I'm trying make a desktop app and don't appear any .js...I can create these but don't work
...in the docs I read things like these:
var win = Ti.UI.createWindow(); var view = Ti.UI.createView({backgroundColor:"red"}); win.add(view); win.open();
I don't know where I've put this code...I try put it inside a javascript inside the html (bad practice!) but it don't work...I put it inside a function onload but don't work neither.....there are any "convention" with the names for the files for this work?...I think this is like create a very dynamic web page but I don't know how work with the api....I see the example "kitchen something" but it wasn't so clear to mee...I see a examples like this:
http://mobile.tutsplus.com/tutorials/appcelerator/appcelerator-using-json-to-build-a-twitter-client/
but seems this work different when is an ipod to when it is a desktp app...I create an app.js (like the tuto) and put my code inside it but it never run...I look the source code and only need create a .js and inside my "home.html" link it..but it don't work...I create a index.js too but it don't work neither
please help..I'm very noob...thanks
Aaron:
This reply kindly brought something that could have been a solution but just made me lose more than 15 minutes of my time, as these first online courses have info about how to create a new project with a default html file, not about the original poster's issue.
The original poster's issue is that he has a new project with an index.html file, but no app.js file.
And he then doesn't understand where he could put the sampe code :
var win = Ti.UI.createWindow();
var view = Ti.UI.createView({backgroundColor:"red"});
win.add(view);
win.open();
... as whatever he puts in app.js is not executed.
The documentation in Titanium Dev Center fails to provide accurate information as it only mentions Titanium Mobile app.js and does not speak of index.html in the application structure.
After some starting experience on Titanium Mobile, I had to work on Titanium Desktop andactually just had the same problem as angel_ang, which brought me here.
So, here is the real answer :
Titanium Desktop applications do not need or start with an app.js file, but with index.html.
Deleting or removing this file never works as it will still be launched from the last build if need be.
Adding anything to app.js will never run as only index.html is run as a starting place.
Something that should have been a solution was found that to the following link:
http://www.youtube.com/watch?v=lgGVNB2nkKc&NR=1
This video is two online courses further from the link supplied by Aaron. At 0.19 seconds exactly, we see the starting code he has added to index.html.
You need to put a ... in your HEAD section, and add a function() there.
You may put the sample code inside this function.
Then you may even set the function to run when you click a button ().
Unfortunately, this doesn't work with me either.
I tried with the example code above but also with the other example (notification) mentioned in the online course.
It just seems that something is deprecated here and many documentations are outdated.
Anyone that could answer to this situation would be very helpful to us and many newcomers.
We just have an index.html that we can't use, instead of a running app.js file.