fix required html5 fields screwing up form submit
This commit is contained in:
parent
85e6d5f524
commit
28b486f188
|
@ -232,4 +232,6 @@ $(function() {
|
|||
<script type="text/javascript" src="/static/js/innertabs.js"></script>
|
||||
|
||||
<br />
|
||||
{% if user_has_perms %}
|
||||
<a href="{{ edit_url }}">Edit</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -45,125 +45,17 @@
|
|||
|
||||
$(function(){
|
||||
$('form.uniForm').uniform();
|
||||
/*
|
||||
$('select').select2({
|
||||
|
||||
});
|
||||
*/
|
||||
/*
|
||||
sampleData = [
|
||||
{
|
||||
'id': 'foo',
|
||||
'text': 'some text',
|
||||
'first_name': 'some',
|
||||
'last_name': 'test'
|
||||
}
|
||||
];
|
||||
*/
|
||||
|
||||
|
||||
$('.select2class').itfSelect2();
|
||||
|
||||
/*
|
||||
$('.select2class').select2({
|
||||
//placeholder: 'Select your connections',
|
||||
//multiple: true,
|
||||
ajax: {
|
||||
url: '/autocompletes/itfprofiles/',
|
||||
dataType: 'json',
|
||||
quietMillis: 100,
|
||||
data: function(term, page) {
|
||||
return {
|
||||
q: term,
|
||||
page_limit: 10,
|
||||
page: page
|
||||
|
||||
}
|
||||
},
|
||||
results: function(data, page) {
|
||||
//console.log(data);
|
||||
var more = data.has_next;
|
||||
//console.log(data);
|
||||
return {results: data.items, more: more};
|
||||
}
|
||||
},
|
||||
formatResult: function(item) {
|
||||
//console.log(item);
|
||||
return "<div>" + item.first_name + " " + item.last_name + "<div style='font-size:12px'><i>" + item.about + "</i></div></div>";
|
||||
},
|
||||
formatSelection: function(item) {
|
||||
//console.log(item);
|
||||
//return "<div>" + item.first_name + " " + item.last_name + "<div>" + item.about + "</div></div>";
|
||||
//console.log("foo");
|
||||
return item.text;
|
||||
//return "<div data-id='" + item.id + "'>" + item.first_name + " " + item.last_name + "</div>";
|
||||
},
|
||||
createSearchChoice: function(term) {
|
||||
s = term.split(" ");
|
||||
first_name = s[0];
|
||||
last_name = s.length > 1 ? s[1] : '';
|
||||
return {
|
||||
'id': "x_" + parseInt(Math.random() * 1000),
|
||||
'text': term,
|
||||
'first_name': first_name,
|
||||
'last_name': last_name,
|
||||
'about': '...'
|
||||
}
|
||||
}
|
||||
//Ugly hack to remove required attribute from inline form fields
|
||||
//that were preventing form submit
|
||||
$('[required]').prop("required", false);
|
||||
|
||||
$('form').submit(function() {
|
||||
$('[required]').prop('required', false);
|
||||
return true;
|
||||
});
|
||||
*/
|
||||
// console.log(sampleData);
|
||||
// $('#id_connections').select2("val", sampleData);
|
||||
|
||||
// var val = $('#id_connections').select2("val");
|
||||
// $('#id_connections').data("old_val", sampleData);
|
||||
/*
|
||||
$('.select2-choices').on("click", function(e) {
|
||||
console.log(e.target);
|
||||
});
|
||||
|
||||
$('#id_connections').bind("change", function(evt) {
|
||||
var $this = $(this);
|
||||
var val = $(this).val();
|
||||
var oldVal = $(this).data("old_val");
|
||||
var newVal = $(this).select2("val");
|
||||
|
||||
var deletedItem = (function() {
|
||||
var ret = false;
|
||||
oldVal.forEach(function(o) {
|
||||
if ($.inArray(o, newVal) == -1) {
|
||||
ret = o;
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
})();
|
||||
|
||||
if (deletedItem) {
|
||||
|
||||
console.log("deleted", deletedItem);
|
||||
}
|
||||
|
||||
var newItem = (function() {
|
||||
var ret = false;
|
||||
newVal.forEach(function(n) {
|
||||
if ($.inArray(n, oldVal) == -1) {
|
||||
ret = n;
|
||||
}
|
||||
});
|
||||
return ret;
|
||||
})();
|
||||
|
||||
//console.log(newItem);
|
||||
if (newItem) {
|
||||
console.log("new item", newItem);
|
||||
}
|
||||
|
||||
var currVal = $(this).select2("val");
|
||||
$(this).data("old_val", currVal);
|
||||
|
||||
});
|
||||
//$('#id_connections').change();
|
||||
*/
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user