JWYSIWYG or jHtmlArea within a Jquery Ui Tab - ajax

I am not able to get my jwysiwyg and Jhtmlarea text editors to work within an AJAX loaded Jquery UI Tab
Both text editors work when loaded normally.
This loads the tabs on the "View Page"
<script type="text/javascript">
$(function() {
$("#tabs").tabs();
});
</script>
This loads the page via AJAX on the "View Page"
<li>Edit</li>
This loads the Html Area on the "Edit Page"
<script type="text/javascript" charset="utf-8">
$(function(){
$("textarea").htmlarea();
});
</script>
All help would be greatly appreciated.
Tim

because you're injecting the things you're trying to htmlarea-ize into the DOM after the page loads, you have to put your $("textarea").htmlarea() inside the callback function of the ajax call.

Related

Remove "Mark Complete" button on Task Ribbon in Project Web App

I would like to remove the "Mark Task Complete" button from the Task Ribbon on my Project Web App to prevent users from clicking on it. I have been successful in adding a custom JavaScript Web Part to hide the button after a 200 millisecond delay because the JavaScript has to wait for the page to load. However, this not only leads to a bad user experience but also it is not guaranteed that the page will fully load in 200 milliseconds and thus leaves the possibility of the users seeing the button and being able to interact with it. Here is that JavaScript.
<html>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("li.ms-cui-tt a:eq(1)").trigger("click");
});
window.onload = function(){
setTimeout(function(){
document.getElementById('Ribbon.ContextualTabs.MyWork.Home.Tasks.MarkComplete-Large').style.display = 'none';
}, 200);
};
</script>
</body>
</html>
Is there a way to accomplish the desired affect without using a delay?
You can use CSS for the same result, note that you have to substitute the dot in the class name with \.
It should look a bit like this (In a Scritp Editor Web Part on the Page):
<style type="text/css">
#Ribbon.ContextualTabs.MyWork.Home.Tasks.MarkComplete-Large {
display: none
}
</style>

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>

Launching FancyBox automatically on 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>

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
});

if ajax function is successful display an alert

I have a jsp named home.jsp. On click of "activate now" button in this jsp, a lightbox is being displayed.
This lightbox has 2 buttons "activate" and "remove".
When I click on "activate" button, a service is being activated. On successful activation, page is reloaded and home.jsp is displayed.
Now i want to display an alert when this happens. Can anyone please help me with this?
Your home.jsp page should queue a JavaScript snippet that runs immediately after the page gets loaded (and once it's activated). I recommend using jQuery which will make this a lot easier. Here is a dirty example:
<html>
<head>
...
<script type="text/javascript">
jQuery().ready(window,function(){
alert("your account is activated");
});
</script>
...
</head>
<body>
...

Resources