jQuery UI Tabs - How to add Tabs - jquery-ui-tabs

I am using jQuery UI Tabs in my page...
$(function() {
$( "#tabs" ).tabs();
});
exemple: http://jsfiddle.net/thiagoluga/hk9a89y1/
Now I want to remove my current tabs and add new Tabs... Is it possible?

Here is a working example of dynamically adding and removing tabs.
Add/remove tabs using jquery
Hoping it helps.
Cheers !!

Related

How to hide element when AdminLTE sidebar is collapsed?

I'm using AdminLTE theme (Bootstrap). I have some custom elements on the sidebar. I want to hide them when the sidebar is collapsed. Is there some specific class to do that?
You can use the collapse event like this:
$(document).on('expanded.pushMenu', function () {
$('.your-special-element').show();
}).on('collapsed.pushMenu', function(){
$('.your-special-element').hide();
});
Instead of show and hide it looks nicer if you use fadeOut and fadeIn

Bootstrap Gallery with Lightbox

I'm using the ekko lightbox along with bootstrap modal to create a gallery. However I cant seem to get the image navigation controls to appear/work like they do on this example: http://ashleydw.github.io/lightbox/#image-gallery
As you can see when you hover over an image you get navigation control arrows. I've tried adding the data attribute data-gallery="multiimages" to my images but this hasnt helped.
You can see my development code here: http://agtdesigns.co.uk/bootstrap-gallery/
Any help appreciated,
tia
I had the same problem,
see https://github.com/ashleydw/lightbox/issues/33 for the answer.
In summary, you need to add a wrapping div, eg
<div class="gallery">
Then as JS code
$(document).delegate('*[data-toggle="lightbox"]', 'click', function(event) {
event.preventDefault();
return $(this).ekkoLightbox({
always_show_close: true,
gallery_parent_selector: '.gallery',
});
});

Dynamic menu button items in TinyMCE

I have a custom menubutton in my tinyMCE editor that uses specific HTML elements elsewhere on the page as the menu items. I use a jQuery selector to get the list of elements and then add one each as a menu item:
c.onRenderMenu.add(function(c,m) {
m.add({ title: 'Pick One:', 'class': 'mceMenuItemTitle' }).setDisabled(1);
$('span[data-menuitem]').each(function() {
var val = $(this).html();
m.add({
title: $(this).attr("data-menuitem"),
onclick: function () { tinyMCE.activeEditor.execCommand('mceInsertContent', false, val) }
});
});
});
My problem is that this only happens once when the button is first clicked and the menu is first rendered. The HTML elements on the current page will change occasionally based on user clicks and some AJAX, so I need this selector code to run each time the menu is rendered to make sure the menu is fully up-to-date. Is that possible?
Failing that, is it possible to dynamically update the control from the end of my AJAX call elsewhere in the page? I'm not sure how to access the menu item and to update it. Something using tinyMCE.activeEditor.controlManager...?
Thanks!
I found a solution to this problem, though I'm not sure it's the best path.
It doesn't look like I can make tinyMCE re-render the menu, so instead I've added some code at the end of my AJAX call: after it has updated the DOM then it manually updates the tinymce drop menu.
The menu object is accessible using:
tinyMCE.activeEditor.controlManager.get('editor_mybutton_menu')
where mybutton is the name of my custom control. My quick-and-dirty solution is to call removeAll() on this menu object (to remove all the current menu items) and then to re-execute my selector code to find the matching elements in the (new) DOM and to add the menu items back based on the new state.
It seems to work just fine, though tweaks & ideas are always welcome!

Add a dynamic text to SP21010 Rich Text Editor when a particular Markup Style is applied

In Sharepoint 2010, I have built a custom page layout and have applied custom styles. Page layout consist of single rich text editor HTML field. Now I have a need to add some custom text next to the selected text when a particular markup Style is applied.
I can do that using jQuery once the page is saved but that is after the user has finished editing.
The requirement is for them to see the text while they are still in edit mode so that they get a true WYSIWYG experience . Below is the jQuery code I am using to display the text after page is saved:
<script type="text/javascript">
$(document).ready(function () {
$('.topicpagelayout2-styleElement-H3').wrap('<div class="hd leftcontent" />');
$('.topicpagelayout2-styleElement-H3').append('<span class="top">Top</span>');
$('.topicpagelayout2-styleElement-H3').addClass('header2');
var count=0;
$('.leftcontent').each(function(index) {
count++;
$(this).attr('id','div_'+count);
});
//$("span.ms-formfieldlabel").css("display", "none");
setLeftContent();
});
</script>
You can use use css content for this.
See this if it may give you some idea
http://www.quirksmode.org/css/content.html

jQuery Masonry wrong top position

I'm using Twitter Bootstrap with fixed layout along with jQuery Masonry on a specific page.
It's working, however starting from the second row the top positions of the divs are miscalculated and are partly covering the elements of the first row.
It looks like the script quits before rearranging the elements.
Strangely, when I open the inspector in Chrome or slightly resize the viewport the divs are jumping to their correct positions. Refreshing the page sometimes helps, sometimes doesn't...
My masonry script:
jQuery(document).ready(function(){
jQuery('.span9').masonry({
itemSelector: '.span3',
columnWidth: function( containerWidth ) {
return containerWidth / 3;
}
});
});
Is this normal behaviour? Should I add window.resize to the above script?
Placing the masonry script in the page itself or in the header, footer doesn't change it's behaviour.
I'm calling masonry.js right after jQuery, before any other Bootstrap js.
Just read the help Section here http://masonry.desandro.com/docs/help.html
The Script runs before all images have been loaded, you have to trigger it after the window loaded
$(window).load(function(){
$('#container').masonry({
// options...
});
});