Launching FancyBox automatically on Magento - magento

I know this was asked before but i couldn't get it to work anyhow. What I am trying to do is to launch FancyBox on page load(on Magento). Seems simple enough but as I am not very familiar with JQuery, i am having some problems. The Code I got the work with manually clicking on the anchor is as follows:
<!-- FancyBox -->
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("a[rel=fancybox]").fancybox({
});
});
</script>
<!-- FancyBox -->
<p><a id="image_id" href="http://shop2.xsmoke.com/skin/frontend/infinitus/maxxi/images/logo-300x71.png" rel=iframeLink><img src="http://shop2.xsmoke.com/skin/frontend/infinitus/maxxi/images/logo-300x71.png" alt="" /></a></p>
What I have so far regarding automatic launch is:
jQuery(document).ready(function(){
$("#image_id").fancybox().trigger('click');
});
The rest is same. Can anyone help?
EDIT: Ok i have been trying to get it to work for hours now and I tried using plain JavaScript for clicking the anchor. I Wrote
function init(){
document.getElementById("image_id").click();
}
window.onload = init;
but it still doesn't click the anchor. When I try it on a basic html page locally it works, but on the Magento home-content.phtml on the server it doesn't.

Try
jQuery(document).ready(function(){
jQuery("a[rel=fancybox]").fancybox({});
jQuery("a[rel=iframeLink]").fancybox({});
$("#image_id").trigger('click');
});
<p>
<a id="image_id" href="http://shop2.xsmoke.com/skin/frontend/infinitus/maxxi/images/logo-300x71.png" rel="iframeLink">
<img src="http://shop2.xsmoke.com/skin/frontend/infinitus/maxxi/images/logo-300x71.png" alt="" /></a></p>

Related

Mailchimp sign up PopUp does not work

I am trying to implement a signup PopUp from Mailchimp but as it seems, I am not able to make it working! Here's the code:
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="http://s3.amazonaws.com/downloads.mailchimp.com/js/signup-forms/popup/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script><script type="text/javascript">require(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"http://mc.us9.list-manage.com","uuid":"146962178e8704d5ccaf9c28f","lid":"e13cc10d95"}) }) </script>
</head>
<body>
<p>This is a test!</p>
</body>
</html>
If I open the html file (locally), it loads but nothing else happen. Also there is no html code embedded what I would expect it to do. Do you have any ideas?
you have to know a couple of things:
this shows your popup on page load (hence no HTML code)
it only shows once since it places a cookie, and if you already saw your popup won't bother you with it again. (try it in private mode in your browser)
Try to add in header this google libraly <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>

CodeIgniter and jQuery Mobile 1.2

I have a CodeIgniter web app I'm trying to convert (UPDATE: I'm trying to overlay the JQM UI) [to a jQuery Mobile app]. I'm having problems setting up tabs that link to my CodeIgniter controllers.
This is the code in my "header.php" view - inside a <div data-role="page"></div>. This is called by a main controller, which works fine. Now, the problem: I am trying to set up my jQuery Mobile navbar tabs to call a new controller called inbox.
<div data-role="footer" data-position="fixed">
<div data-role="navbar">
<ul>
<li>
Inbox
</li>
</ul>
</div>
</div>
Without jQuery Mobile, the link works fine and triggers the Inbox CodeIgniter controller, but with JQM enabled in my header.php view, I get a "404 Not Found" page when I click on the Inbox tab.
Update - this jQuery code in the html head:
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/all-mobile.css" type="text/css" media="screen"/>
<link rel="icon" href="<?php echo base_url(); ?>assets/images/logo.png" />
<link rel="apple-touch-icon-precomposed" href="<?php echo base_url(); ?>assets/images/logo.png" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
Update 2: If I insert this code in t.js to remove the automatic ajax links:
$(document).bind("mobileinit", function(){
$.mobile.ajaxEnabled = false;
});
and my new head html code is now:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="<?php echo base_url(); ?>assets/js/t.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
… the jQuery Mobile does load up but the "inbox" link still generates a 404 page by CI.
UPDATE 3: I determined it's a problem with something local. When I upload the CI code and the new jQuery Mobile scripts to my web server, the tab linking to my inbox.php controller does in fact work! Does anyone know why it doesn't work on my local machine using MAMP? Now, it appears that I can't develop and test locally with this configuration. Is there a fix?
Looking at allowCrossDomainPages at jquerymobile.com/demos/1.2.0/docs/api/globalconfig.html I added $.mobile.allowCrossDomainPages = true; to the jQuery initialization but it did not help the localhost server running MAMP serve up the inbox.php controller - still 404.
UPDATE 4: PROBLEM SOLVED. It turns out there was a problem in the hidden file .htaccess. To rewrite the URI, it contains a "RewriteBase /myapp-mobile/"; this directory became incorrect when I moved it over to the new folder under htdocs.
As per the documentation:
Working with jQuery Mobile's Auto-initialization - Unlike other jQuery projects, such as jQuery and jQuery UI, jQuery Mobile
automatically applies many markup enhancements as soon as it loads
(long before document.ready event fires).
And...
ajaxEnabled (boolean, default: true): jQuery Mobile will automatically handle link clicks and form submissions through Ajax,
when possible. If false, url hash listening will be disabled as well,
and urls will load as regular http requests.
Looks like it treats all links as ajax requests unless you specifically set that option to false within the mobileinit function, which you don't yet have.
Use this function below to force jQuery mobile to treat all links as normal http requests.
$(document).bind('mobileinit', function(){
$.mobile.ajaxEnabled = false;
// other options to enable on intialization
});

my ckeditor is not loading the toolbar

I tried to install ckeditor in php but no result :S.
i have uploaded ckeditor file into the root of the site and i have a editor.html file where i have this code:
<html>
<script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
<form method="post">
<p>
My Editor:<br />
<textarea id="editor1" name="editor1"><p>Initial value.</p></textarea>
<script type="text/javascript">
CKEDITOR.replace( 'editor1' );
</script>
</p>
<p>
<input type="submit" />
</p>
</form>
when i open the page it doesnt show the toolbar except a simple textarea.
Does any of you knows what I am actually missing here?
I don't know if this was your case, but in case it helps anyone else in the future...
I was adding CKEditor to my project and the toolbar wasn't showing for me either. I could tell the javascript file was loaded (and css files). There were no javascript errors either.
Eventually I narrowed it down to a conflict between a jquery plugin (jquery.stylish-select) and CKEditor. When I removed the plugin, the toolbar showed up perfectly.
Maybe you can try this:
CKEDITOR.replace('editor1', {width: 1050, height: 500, uiColor: '#e1e1e1'});
that means, you change the size....
So, can be, that it is better to use this CODE

dojo.connect not working in IE but sometimes in chrome&firefox

I finally got some parts working here: http://jsfiddle.net/trXBr/5/
but when I put the code back into my project and tried to browse using internet explorer; the button onclick events do not work. Interestingly the one button onclick function to show the dialog works in firefox and chrome. I was excited to have this working in the editor but now if this does not work with all browsers, then this is just really frustrating. I am using version 1.5.1
dojo.connect(loadBtn,'onClick',function(){
userDialog.show();
});
dojo.connect(butt,'onClick',function(evt){
showTab();
});
Any help/ideas appreciated.
EDIT:
Ok using the compatibility mode in IE helps to get the one function working which displays the dialog box.
So as you can see here I have an borderlayout where I want a tabcontainer to be displayed in the middle with a click of a button and this works fine in jsfiddler but not from my code in the browsers;
<div dojoType="dijit.layout.ContentPane" region="center" splitter="true">
<div id="mainTabContainer"dojoType="dijit.layout.TabContainer"
style="width:500px;height:100px;display:none">
<div id="tab1" dojoType="dijit.layout.ContentPane"
title="First Tab" selected="true"
closable="true">First Tab</div>
<div id="tab2" dojoType="dijit.layout.ContentPane"
title="Second Tab" closable="true">
Second Tab
</div>
</div>
</div>
so the display:none but when I click the button I call the following:
dojo.connect(butt,'onClick',function(evt){
showTab();
});
function showTab(){
dijit.byId("mainTabContainer").domNode.style.display = 'block'
dijit.byId("mainTabContainer").resize();
}
Also if I remove the display=none then the tabcontainer appears fine. So is these something wrong with my function call.
ok sorry guys....all my fault here...I forgot to remove the added code I had in my html in my asp.net code
<body class="claro">
<form id="form1" runat="server">
<asp:ScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ScriptManager>
Once I removed the form and scriptmanager lines it works fine..Thanks for everyones efforts.
Just worried that if I were to incorporate ajax and other controls, then would dojo still work

How do I place a magento autocomplete mini search box outside the magento installation?

I would like to put a magento mini search box in my main website, so that when a search is made, it redirects to the magento search results page. This global search is in the header and helps to find products fast on my Codeigniter main site. I was able to achieve part of this, by placing the following code:
<form method="get" action="http://pathtomagento/catalogsearch/result/" id="search_mini_form">
<div class="form-search">
<label for="search">Buscar:</label>
<input type="text" class="input-text" value="" name="q" id="search" autocomplete="off">
<button class="button" title="Buscar" type="submit"><span><span>Buscar</span></span></button>
<div class="search-autocomplete" id="search_autocomplete" style="display: none;"></div>
<script type="text/javascript">
//<![CDATA[
var searchForm = new Varien.searchForm('search_mini_form', 'search', 'Buscar en el catálogo...');
searchForm.initAutocomplete('http://pathtomagento/catalogsearch/ajax/suggest/', 'search_autocomplete');
//]]>
</script>
</div>
The autocomplete function of the search box doesn't work, which is a main issue for me since it's a really useful feature. My main website is full of jQuery, and I know Magento uses prototype. So I managed to include the following scripts that seem to be required by the autocomplete Magento search box:
<script type="text/javascript" src="pathtomagento/js/prototype/prototype.js"></script>
<script type="text/javascript" src="pathtomagento/js/varien/js.js"></script>
Still no luck! I don't get any Console errors in Firebug, but I don't get any AJAX or autocomplete response either. Does anyone know what I could be missing?
Your magento installation has to be on the same server because you can't make crossdomain AJAX requests. Maybe that is the problem in your case?

Resources