Hello,
Is there a way to know that the user is closing the navigator, and/or the tab in Safari for iPhone, so that I can save data to localStorage, or do I need to do it for every input ?
If I have a selector like
$.('.active');
How can I see how many items that matched?
Alternatively, is there an easy way to see if more than zero elements were matched?
Is it possible to create the following behavior with one or more existing JQuery plugin(s)/widget(s)... or with some other web framework?
Rectangular divs with textual content are arranged in rows (left to right) based on their sort order, and then flow to the next line if needed (top to bottom).
This is mostly a language-agnostic question.
If I'm waiting for two events to complete (say, two IO events or http requests), what is the best pattern to deal with this. One thing I can think of is the following (pseudo js example).
request1.onComplete = function() {
req1Completed = true;
eventsCompleted();
}
request2.onComplete = function() {
req2Completed = true;
eventsCompleted();
}
eventsCompleted = function() {
if (!req1Completed || !req2Completed) return;
// do stuff
}
Is this the most effective pattern, or are there more elegant ways to solve this issue?
I am using the code in example http://www.faridesign.net/2012/05/create-a-awesome-vertical-tabbed-content-area-using-css3-jquery/ I am trying to slide the div tags on a button click on the list so the current tab-content will slide in and the tab just clicked will slide out. I currently have the working example where I can switch between divs fine, but I need to slide in and out between divs. Is there any script I can do this with the current code. using .slide or .effect instead of .show() looks to display two divs at the same time. I'm not sure what I am doing wrong.
<div id="v-nav">
<ul>
<li tab="tab1" class="first current">Main Screen</li>
<li tab="tab2">Div 1</li>
<li tab="tab3">Div 2</li>
<li tab="tab4">Div 3</li>
<li tab="tab5">Div 4</li>
<li tab="tab6">Div 5</li>
<li tab="tab7">Div 6</li>
<li tab="tab8" class="last">Div 7</li>
</ul>
<div class="tab-content">
<h4>Main Screen</h4>
</div>
<div class="tab-content">
<h4>Div 1</h4>
</div>
<div class="tab-content">
<h4>Div 2</h4>
</div>
<div class="tab-content">
<h4>Div 3</h4>
</div>
<div class="tab-content">
<h4>Div 4</h4>
</div>
<div class="tab-content">
<h4>Div 5</h4>
</div>
<div class="tab-content">
<h4>Div 6</h4>
</div>
<div class="tab-content">
<h4>Div 7</h4>
</div>
My Script looks like
$(function () {
var items = $('#v-nav>ul>li').each(function () {
$(this).click(function () {
//remove previous class and add it to clicked tab
items.removeClass('current');
$(this).addClass('current');
//hide all content divs and show current one
//$('#v-nav>div.tab-content').hide().eq(items.index($(this))).show();
//$('#v-nav>div.tab-content').hide().eq(items.index($(this))).fadeIn(100);
$('#v-nav>div.tab-content').hide().eq(items.index($(this))).slideToggle();
window.location.hash = $(this).attr('tab');
});
});
if (location.hash) {
showTab(location.hash);
}
else {
showTab("tab1");
}
function showTab(tab) {
$("#v-nav ul li:[tab*=" + tab + "]").click();
}
// Bind the event hashchange, using jquery-hashchange-plugin
$(window).hashchange(function () {
showTab(location.hash.replace("#", ""));
})
// Trigger the event hashchange on page load, using jquery-hashchange-plugin
$(window).hashchange();
});
I don't know how to search about this so I'm kinda lost (the two topics I saw here were closed).
I have a news website and I want to warn the user when a new data is inserted on the database. I want to do that like here on StackOverflow where we are warned without reloading the page or like in facebook where you are warned about new messages/notifications without reloading.
Which is the best way to do that? Is it some kind of listener with a timeout that is constantly checking the database? It doesn't sounds efficient...
Thanks in advance.
I am using replaceWith for input type=file to handle changes of the file the user wants to upload.
I have this code:
$('#add_cv_input').change(function() {
// here is some code
else {
alert('put one of this: pdf doc docx');
$("#add_cv_input").replaceWith('<input id="add_cv_input" type="file"/>');
}
});
now the problem is that this jquery changed event does not being called after the first time that the user had uploaded the wrong extension.
I don't have a clue why this is happening. Everything works fine if at the first time the user uploads a valid extension and then he changes it to other valid extension.
Welcome,
It it possible to select all checkboxes / uncheck all checkboxes what have class "xxx" ?
I can't use "name" and "ID" because there are generated dynamical via PHP and i don't know their name.
So maybye i can add class "xxx" for these what i wan't control ?
Is is possible ?
Or, if not possible.
Maybye i can select all / unselect what are inside table with id "selectall" ?
Regards
I am currently trying to implement a jquery slider into a joomla website.
I already implemented NoConflict(); so that it doesn't step into joomla. And it works, BUT for another reason wich I do not understand it enters another jquery file called jsloader.js of a plugin I use for picture gallery display.
I suppose all the module jquery files get preloaded before the one im calling inside the template.
it enters the function() in the jsloader.js instead of the one in my jquery file.
How Can I force it to enter my jquery file instead of other
Is there any way to get the collection of all textNode objects within a document?
getElementsByTagName() works great for Elements, but textNodes are not Elements.
Update: I realize this can be accomplished by walking the DOM - as many below suggest. I know how to write a DOM-walker function that looks at every node in the document. I was hoping there was some browser-native way to do it. After all it's a little strange that I can get all the <input>s with a single built-in call, but not all textNodes.
I'm trying to implement word boundaries in my emoticons feature for a chat. But for some reason I can't seem to get the word boundaries to work. I am new to regex.
So when I do:
var reg = /\b\Hi\b/gi;
var str = 'HiHiHi Hi HiHiHi Hi';
alert(str.replace(reg, ''));
This happens: Jsfiddle
It actually works fine, and does remove those 2 Hi's that are standing alone.
But when I change the reg to an escaped smiley and then change the string:
var reg = /\b\:\)\b/gi;
var str = 'HiHi:) :) HiHiHi :)';
alert(str.replace(reg, ''));
This happens:
Jsfiddle
It just doesn't work. The string stays the same. Is it that word boundaries can't be used on symbols? If so, how does Facebook do it on their chats?
Is there any possible way to pass any extra parameter instead of date in schedule.scheduleJob(date,function(id))
The below code is not working
var id =record.id;
var date =record.date;
jobsCollection.save({
id: record.id
}, {
$set: record
}, function (err, result) {
var j = schedule.scheduleJob(date, function (id) {
return function () {
console.log("inside----------")
console.log(id)
};
}(id));
if (!err) {
return context.sendJson([], 404);;
}
});
i want to pass the date along with another data to schedule jobs. so that i can perform other operations based on the date schedule and that id
Hello everyone:
I will work on a search box with inspiration from Facebook where image thumbnails would be displayed besides the auto-suggested matches.
This is the goal : link to sample image
I wonder if there is any jQuery plugin that would just do this. I tried to search for a one but unable to find.
If there is no plugin for this task, I'd like to know the basic plugins needed to implemented such an auto-suggest/image thumbnail display combination.
Any suggestion and hint is welcomed. Thanks a lot!
I need to apply/remove to an input field according to a user's selection in a separate drop down form - but I can't figure out how to target the input's class.
I need to add/remove the 'pageRequired' class from this input:
<input type="text" title="Company Required" name="customfields-tf-2-tf" class="inputclass pageRequired textInput" id="customfields-tf-2-tf" />
When the user selects one of two options from a drop down field. For example:
<select class="dropdown" name="customfields-s-1-s" id="customfields-s-1-s" >
<option value="Owner"<?php if(in_array("Owner",$temp_values)) { ?> selected='selected'<?php } ?>> Owner</option>
<option value="Broker"<?php if(in_array("Broker",$temp_values)) { ?> selected='selected'<?php } ?>> Broker</option>
</select>
If the user selects broker than I want to add the pageRequired class to the first input field and remove it if the user selects Owner.
This is frustrating me. It should be something really simple but I can't get it to work IE. I want to get the height of the current window. Not the scroll height, not the document height, the actual window height. I've tried window.innerHeight which returns undefined and document.documentElement.clientHeight which gives the scroll height.
I am using asp.net.
I have taken one Hidden value and assigning value to that hidden variable in Java-script.
aspx: <input type="hidden" runat="server" id="hdnProductionIds" value="0" name="hdnProductionIds" />
JS:
document.getElementById("ctl00_ContentPlaceHolder1_hdnProductionIds").value = "123";
I want to use that hidden value in server side coding(vb.net). But while do-post back, hidden variable value becomes Zero (default value)
Can any one please suggest me.
Thanks, Jagadi.
Sequential Asynchronous calls are gross. Is there a more readable solution?
The problem is this is hard to follow:
ajaxOne(function() {
// do something
ajaxTwo(function() {
// do something
ajaxThree()
});
});
where the anonymous functions are callbacks that are called on server response.
I'm using a third party API to make the AJAX calls, so I need a generic solution.
First, I can assume that all urls that end with jpeg, jpg, bmp, png or gif are images, and others aren't.
I thought of, and tried two solutions:
Matching the regular expression .(jpe?g|bmp|png|gif)$
Using ends-with to check each separately
But, it appears that neither of these exist in XPath 1.0, or at least, they don't exist in Firefox (I am writing a greasemonkey script, so it is only important for the path to work in Firefox).
The code below works as expected in FF but not in IEs...
$(document).ready(function() {
$('div.facet_dropdown select').live('change', function() {
var changed_facet = $(this).attr('id');
var facets = $('select', $(this).closest('form'));
var args = window.location.href.split('?')[0] + '?ajax=1';
var clear = false;
for(var i = 0; i < facets.length; i++) {
var ob = $(facets[i]);
var val = ob.val();
if(clear) {
val = '';
}
args += '&' + ob.attr('id') + '=' + val;
if(ob.attr('id') == changed_facet) {
clear = true;
}
}
$.getJSON(args, function(json) {
for(widget_id in json) {
var sel = '#field-' + widget_id + ' div.widget';
$(sel).html(json[widget_id]);
}
});
});
});
How can I return the value "pinNumber" from jquery ajax so I can append it outside of the ajax. Here is my code
var x = pinLast + 1;
for(i=x;i<=pinMany;i++) {
var i = x++;
var cardNumber = i.toPrecision(8).split('.').reverse().join('');
var pinNumber = '';
jQuery.ajax({
type: "POST",
url: "data.php",
data: "request_type=generator",
async: false,
success: function(msg){
var pinNumber = msg;
return pinNumber;
//pin number should return
}
});
jQuery('.pin_generated_table').append(cardNumber+' = '+pinNumber+'');
// the variable pinNumber should be able to go here
}
Please ask me if you don't understand.. ^^ thanks
I'm trying to make a pull down menu post a form when the user selects (releases the mouse) on one of the options from the menu. This code works fine in FF but Safari, for some reason, doesn't submit the form. I re-wrote the code using jquery to see if jquery's .submit() implementation handled the browser quirks better. Same result, works in FF doesn't work in safari.
The following snippets are from the same page, which has some django template language mixed in.
Here's the vanilla js attempt:
function formSubmit(lang) {
if (lang != '{{ LANGUAGE_CODE }}') {
document.getElementById("setlang_form").submit();
}
}
Here's the jquery attempt:
$(document).ready(function() {
$('#lang_submit').hide()
$('#setlang_form option').mouseup(function () {
if ($(this).attr('value') != '{{ LANGUAGE_CODE }}') {
$('#setlang_form').submit()
}
});
});
and here's the form:
<form id="setlang_form" method="post" action="{% url django.views.i18n.set_language %}">
<fieldset>
<select name="language">
{% for lang in interface_languages %}
<option value="{{ lang.code }}" onmouseup="formSubmit('{{ lang.name }}')" {% ifequal lang.code LANGUAGE_CODE %}selected="selected"{% endifequal %}>{{ lang.name }}</option>
{% endfor %}
</select>
</fieldset>
</form>
My question is, how can I get this working in Safari?
Hi,
I have a function called using an anchor inside a form, and I need to get the values of the inputs inside the same form to perform certain actions. Problem is, the result is always undefined.
Here's the code :
$('#create_alert').live('click', function(e) {
var form = $(this).parent().get(0);
var id = $(form).find('input[name="id"]').val();
alert(id);
});
.. and the context :
<form name="create_alert">
<input type="hidden" name="id" value="1" />
<a href="#" type="text" id="create_alert" class="search-submit">CRIAR ALERTA</a>
</form>
Thoughts?
Hi Guys,
I have data which sits outside an iframe with a script on the outside as well. When a user performs an action - I want this ata to be sent "inside" the iframe.
I have having a bit trouble achieving this and was wondering whether its possible and if it is, how I can do it ?
Thx
Ok, I have this code.
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("juliver", $con);
$result = mysql_query("SELECT * FROM items");
while($row = mysql_fetch_array($result))
{
$hi1='<img src="'.$row['name'].'" />';
$hi2= $row['title'];
$hi3= $row['description'];
$hi4= $row['link'];
}
Now, Im in a process of making those records above to display in a table view and that 4 row should be on one td and so the rest.