jquery data tag - javascript

I have the following setup
<div onclick="EditCalendarEvent('#_schedulerEvent.SchedulerID','#_schedulerEvent.SchedulerItemID', event)"
class="ScheduleEvent_Draggable ScheduleEvent"
data-schedulerID="#_schedulerEvent.SchedulerID"
data-schedulerItemID="#_schedulerEvent.SchedulerItemID">
#_schedulerEvent.Subject
</div>
alert($(ui.draggable).attr("data-schedulerID"));
alert($(ui.draggable).data("schedulerID"));
The first alert returns the proper ui, the second alert statment return undefined.

Which version of jQuery you are using. http://api.jquery.com/data/
Please use the latest version of jQuery. This is effective from 1.4 version. Please visit the above link for more information.

Related

Intercooler.js - ic-target reloads intercooler-code and then is not working anymore

I am using intercooler.js in a django project.
http://intercoolerjs.org
<div id=right_side>
<form ic-post-to="{% url 'update-task-ajax' %}" ic-target="#right_side">
[...]
</form>
</div>
The form itself gets reloaded in the div #right-side after the first (working) use and after that intercooler is not working anymore. How to fix this?
Update:
Looks like i have to use
Intercooler.ready(func(elt))
http://intercoolerjs.org/reference.html
But i'm stuck how to use it properly.
I don't see anything wrong about this, the form should keep submitting and targeting #right_side each time, unless you are replacing it somehow. I don't see why Intercooler.ready() is necessary, given the code. Can you clarify what are trying to accomplish?
I'm availabe on the gitter chat for intercooler to help:
https://gitter.im/intercooler-js/Lobby

Input date don't work on safari

Date calendar doesn't work on safari browser but work correctly on other browser.
This is my code for the input date :
<div class="col-lg-4 col-xs-6">
<label for="exampleInputEmail1">Date de :</label>
<input type="date" required class="form-control" ng-model="date_debutOP">
</div>
According to MDN,
input[type=date] is recognized but there is no UI.
Meaning, the browser doesn't have a calendar-like display for such input controls.
You could also refer to caniuse.com to check for compatibility for such features.
The input-type Date is n newer one which isn´t supported on each browser. It´s just a field-validation and in some browsers there is a datepicker.
First only Chrome and now Firefox/..., too.
You could use this instead and it´s very simple:
JavaScript Datepicker
Maybe a bit late, but better late then never ;-)
This works for me:
Add this to your functions.php:
add_filter( 'wpcf7_support_html5_fallback', '__return_true' );
Then add this to your custom css:
div#ui-datepicker-div { z-index:1000!important; }
The inputfield still looks empty, but when you click on it, it will open the datepicker.

unable to get iris colorpicker on jsfiddle

http://jsfiddle.net/zu5uv650/4/
In my HTML window I have this:
<input type="text" id='color-picker' value="#bada55" />
In my JS window I have this:
jQuery(document).ready(function($){
$('#color-picker').iris();
});
I'm using jQuery 2.1.0 as my framework and am using the following external resources:
http://automattic.github.io/Iris/javascripts/iris.min.js
http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js
https://cdn.rawgit.com/Automattic/Iris/master/src/iris.css
...and I'm getting a Uncaught TypeError: undefined is not a function error. Any ideas?
Also, jquery UI has a CSS component too. Does jsfiddle.net really not have the ability to auto include JQuery UI?
Your load order is incorrect: jQuery UI should come before the iris.min.js file. Fiddle.
jquery-ui.min.js
iris.min.js
iris.css

I'm having some trouble trying to get my script to change a element

I have a built a small form on a Drupal site with the following code:
<form id="form">
<button class="btn calc" id="calculator" onclick="return false">Submit</button>
<div class="calcAnswer">£ <span id="result">no value</span></div>
</form>
I would like to use JavaScript to automatically replace the #result element with a value once the button is clicked.
I'm trying this code (but can't seem to get it working:
jQuery(document).ready(function ($){
$("#calculator").click(function () {
$("#result").replaceWith('<span id="result">A new value</span>');
});
});
I have been testing in a JSFiddle (http://jsfiddle.net/NFQpw/8/) but am getting nowhere.
Actually, the problem with your fiddle is that you have "No-Library (pure JS)" specified. You need to include jQuery, and your script will work as expected (on the left bar, under "Frameworks & Extensions", select a version of jQuery). There's nothing wrong with your jQuery.
That said, I agree with #Stijn Martens, using .html('A new value') is cleaner; there's no reason to use .replaceWith in this instance.
You can see it working here: http://jsfiddle.net/Jammerwoch/NFQpw/12/
You just need to set the html inside the #result span. Using the .html() function.
jQuery(document).ready(function ($){
$("#calculator").click(function () {
$("#result").html('A new value');
});
});
http://jsfiddle.net/Stijntjhe/NFQpw/10/
try this one. just include JS: link
jQuery(document).ready(function ($){
$("#calculator").click(function () {
$("#result").replaceWith('<span id="result">A new value</span>');
});
});
It's working, but you're testing with pure Javascript, not jQuery
set on Frameworks & Extensions in the left menu the option jQuery 1.10.1
and it will work

Jquery Selector not working in IE7

For the following HTML
<div id='parent'>
<input id='child' type=hidden value=''/>
</div>
I am doing
$('#parent #child').val('test')
OR
$('#parent > #child').val('test')
but none of the above is working in IE7. It does work in Firefox though
Any idea why is it not working ?
is it because you've got the HTML wrong? You should use " for attribute values. Sometimes IE is more sensitive to these things than Firefox
Your syntax seems correct. The only stuff I can think of that can muck this up are:
Make sure you've got your code between a $(document).ready() block
Maybe try .prop() instead of .attr() if you're using jQuery 1.6+
Try $('#child').val('test'); which would probably give the same result.

Categories

Resources