JQuery mobile Select Option text too long - forms

I'm having a problem with select fields in my forms.
It's a single select field, so JQuery turns it into a button which I can tap on to select the respective option. If the text that option is rather long, then the select button becomes wider than the screen, so it's only partly visible.
I checked the that gets created by JQuery to display the button and it has the CSS 'overflow: ellipse' set, so when I give said span a fixed width smaller than the screen width the option text gets truncated with '...' and everything looks fine.
Is there a way to trigger that behaviour automatically?
the 'viewport' meta-tag is set to 'width=device-width, user-scalable=no'

It maybe late, but I hope someone else can find this helpful.
If the select is wrapped in a fieldset tag, replacing it with a div can fix the problem.

I was also looking for ways to set the width of the select box, but after googling for a long time, I gave in and just shortened the text that is displayed in the select control.
<script type="text/javascript">
$('#myselect').change(function () {
var sel = $("#myselect option:selected").text().substring(0, 20);
$("#myselect option:selected").text(sel);
});
</script>
I know this isn't much helpful, but it has come to my understanding that the select box is one of the toughest to interact with, or at lest, that's what the internet is saying.
I'll throw in a "JQuery select cheat sheet" which I found helpful in my pursuit of a solution -> http://comp345.awardspace.com/select_element_cheatsheet.pdf

Related

TinyMCE get form content without using submit button

I'm trying to put TinyMCE on my website. I figured out how to get it to show up, but I'm lost on how to process the content. In their example, they just have a link that references the top of the page and clicking on it somehow magically causes their dump.php script to execute. I don't understand what's going on here. Here is the link:
http://www.tinymce.com/tryit/basic.php
The "Submit" button at the bottom is really a link in a span element with href="#". The form action is dump.php. I want to know how they configured this to run without an actual submit button. Any help in understanding this is greatly appreciated!
To Get Content From Tinymce You Can Use GetContent Method of Currently ActiveEditor Instance
tinyMCE.activeEditor.getContent();
method is used to getting Content .. to Set The Content
tinyMCE.activeEditor.setContent("I Want Text To Be in Tinymce");
to find a perticular element in tinymce get body and find element
var body = tinyMCE.activeEditor.getBody();
$(body).find("#elem_id")
to get a full html
tinyMCE.activeEditor.getDoc().documentElement.innerHTML
hope that helps ..
Since I use PHP, I found this which is also useful:
http://www.tinymce.com/wiki.php/TinyMCE3x:How-to_implement_TinyMCE_in_PHP

Preventing page jump - hashed anchor tag - default behavior

I made a type of menu box with css click events using targets and link them with hash anchor tags. The problem is, when I click one of the buttons (One, Twii, Thrii, etc.) the page jumps! I tried using a js script to stop the default behavior but to no luck. Could you please help me stop the page jump so the page does not move when a button/link is clicked!
Heres the JS Fiddle link I made. jsfiddle.net/3ASpX/1/
I need a solution..whether its with using target or something else!
Thank You and I apoligize for any confusion in explanation and the question itself if I have done something wrong, your help is much much much appreciated.
I think you could do this by using <div> instead of <a>.
But if you have to use an <a>, you could remove the target with jQuery:
$( '.link' ).removeAttr("href");

TinyMCE - editor changing pasted content

Two questions and maybe they are caused by the same thing/setting.
Using TinyMCE with full corporate account. Many of the publishers are just pasting HTML into the HTML Source Editor... we are just getting this going the results are very mixed.
So if someone has a well coded page it works well - as far as we think.
But if you create a page with a couple of (or one) open div tag. Holy cow! The editor can throw divs everywhere - 30 extra on one page someone sent me. Why is the editor changing content? Can we keep this from happening? If a publisher makes an HTML mistake we would rather that the mistake shows - not be scrubbed.
Also I noticed myself when creating menus that if you put in anything inside a link tag (like a div, ul, li, dd, dt, dl, h1-6... pretty much any tag) other than a span, that the editor will either push the tag content outside of the link tag or it will change the tag to a span.
http://www.tinymce.com/wiki.php/Configuration:Cleanup/Output
Looks like the verify html is the new setting. Will report back after testing.
David - I would have marked yours as right if you answered. Looks like that works for 3.4 and below.
For version 3, use
verify_html : false
From here http://archive.tinymce.com/wiki.php/Configuration3x:verify_html

Slide overlayment to side -100%

The script I'm looking for is a "full screen" overlayment (div) which directly onpageload slides to left:-100% and the lower div / page will be visible.
I've been searching and testing for a while now but I can't seem to find a good and easy script.
I think the script would look a bit like this:
<script type="text/javascript">
$(function() {
$('#activator').click(function(){
$('#overlay').fadeIn('fast',function(){
$('#box').animate({'left':'0'},500);
});
});
$('#boxclose').click(function(){
$('#box').animate({'left':'100%'},500,function(){
$('#overlay').fadeOut('fast');
});
});
});
</script>
Is there anyone who knows some panel or slide script I can use for this?
If I've understood what you were asking correctly, here is my solution -
http://jsfiddle.net/davemcmillan/zJryc/
Basically, in the javascript you first setup variables for the width and height of your container. You then set the overlay to have the width and height of your container.
Then you create the toggle function which just looks to see if the #overlay div has a class of 'closed' or not. If it has the class of 'closed', the onclick of the button will open the overlay, and if it doesn't, it will close it.
If you want the panel to open onload, you can just un-comment where I said in the Fiddle link.

jQuery Show/Hide divs using same class not working because of html.push?

The object is to Show-Hide text located under their respective Titles, so a User reads the title and shows or hides text belonging to that title if the User wants to read more.
I tried whatever I could find so far on here, we're talking dynamically setting text coming from a spreadsheet, can't use IDs, must work with .class, must be missing something, I have this piece of code:
... html.push('<div class="comments">' + comment + '</div></div></div>');
but when I try this Show-Hide code nothing happens, even if the error console shows nothing. Basically I want to Show-Hide the .comments class divs with a show-hide toggle link located under each of them. I say them because the .comments divs are reproduced dynamically while extracting text coming from Google spreadsheet cells/row (one .comments div per spreadsheet row). I tried .next, child and parent but they all divorced me so I dunno looks like a dynamic issue. So far I only managed to globally toggle all divs to a visible or hidden state but I need to toggle independantly individual divs.
I prefer a jQuery solution but whatever worked so far was achieved with native javascript.
Note: If a cross-browser truncate function which would append a more-less link after a number of words (var) in each .comments divs would be easier to implement then I would gladly take that option. Thx for any help, remember I am still learning lol!
I have been working on an entirely JS UI project and have brought myself to using $('', { properties }).appendTo(BaseElement) to work best for adding HTML elements because it appropriately manipulates the DOM every time.
If you are having good luck with push elsewhere, however, breakpointing on the line where you do your $('.class').hide() and see what $('.class').length is. Alternately, you can just add alert($('.class').length) to your code if you are unable to breakpoint the code. If it is 0, then your elements have not been properly added to the DOM. Changing to append will ensure they are part of the DOM and therefore targetable via JQuery.