fix required html5 fields screwing up form submit

This commit is contained in:
Sanjay B 2015-08-02 16:51:57 +05:30
parent 85e6d5f524
commit 28b486f188
2 changed files with 9 additions and 115 deletions

View File

@ -232,4 +232,6 @@ $(function() {
<script type="text/javascript" src="/static/js/innertabs.js"></script> <script type="text/javascript" src="/static/js/innertabs.js"></script>
<br /> <br />
{% if user_has_perms %}
<a href="{{ edit_url }}">Edit</a> <a href="{{ edit_url }}">Edit</a>
{% endif %}

View File

@ -45,125 +45,17 @@
$(function(){ $(function(){
$('form.uniForm').uniform(); $('form.uniForm').uniform();
/*
$('select').select2({
});
*/
/*
sampleData = [
{
'id': 'foo',
'text': 'some text',
'first_name': 'some',
'last_name': 'test'
}
];
*/
$('.select2class').itfSelect2(); $('.select2class').itfSelect2();
/* //Ugly hack to remove required attribute from inline form fields
$('.select2class').select2({ //that were preventing form submit
//placeholder: 'Select your connections', $('[required]').prop("required", false);
//multiple: true,
ajax: { $('form').submit(function() {
url: '/autocompletes/itfprofiles/', $('[required]').prop('required', false);
dataType: 'json', return true;
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': '...'
}
}
}); });
*/
// 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();
*/
}); });