purtuga / SPWidgets

Sharepoint Custom UI Widgets
74 stars 34 forks source link

SPFilterPanel is truncating checkbox value at the 1st whitespace in IE 8 SP2010 #43

Closed jamesjh closed 9 years ago

jamesjh commented 9 years ago

in chrome I get:

<input name="SharedTechnologyImpact" title="SharedTechnologyImpact" type="checkbox" value="Test Column" class="spwidget-input spwidget-filter-input">

in ie 11 <input name="SharedTechnologyImpact" title="SharedTechnologyImpact" class="spwidget-input spwidget-filter-input" type="checkbox" value="Test Column">

but in ie 8 I get:

<INPUT class="spwidget-input spwidget-filter-input" title="SharedTechnologyImpact" type="checkbox" name="SharedTechnologyImpact" Column="" value="Test" />

so setFilter is not working and I can't program against the checkbox values.

it was working in IE 8. It stopped some time in the past 2 weeks. I don't know if there was an update or patch. so I did a test using spservices getlist and logged the responsein IE 8 and it does show the choice fields correctly, EG: <Choice>Test Column</Choice>

I tried upgrading to SPWidgets 2.5 - that didn't fix it. Thanks in advance for any help you can provide

purtuga commented 9 years ago

I think you are reporting a problem against setFilter method correct? Could you post your code of its usage?

Also, what version of jQuery are you using?

jamesjh commented 9 years ago

I am using jquery-1.11.1.min.js the problem is the checkboxes are being rendered incorrectly in IE 8. If the choice value has a whitespace, such as 'Test Column,' the value attribute of the checkbox is rendered as 'Test' In this example I should have used 'Test Choice' instead of 'Test Column.' that would make more sense. This is a new issue - your great widget was working correctly in IE 8

$(document).ready(function () {

$("#mainForm").SPFilterPanel({ showFilterButton: false, textFieldTooltip: '', filterButtonLabel: 'Save', list: 'Project Charters',
columns: ['SharedTechnologyImpact', 'ImpactedLinesOfBusiness'],
    onFilterClick: function (filters) { doSubmit(filters, list); }

}); 

});

purtuga commented 9 years ago

Ok... I think I know what the problem is. But to make sure, can you run this in the console (I forget: is there a console in IE8? :) ) and let me know what the output is:

alert($('<div><input value="test"/></div>').html())

(I'm expecting to see "test" without the quotes)

I'll post a fix soon (like maybe tonight).

jamesjh commented 9 years ago

thanks so much! unfortunately the effect is: <INPUT value=test>

purtuga commented 9 years ago

Ok... good... That is what I was expecting and I'm pretty sure I know the problem...

I uploaded a temporary patch here: https://gist.githubusercontent.com/purtuga/4398408fc193ce29c957/raw/fad23c260c77aaa984b22a05d6b4c5a1e6e9cdaf/jquery.SPWidgets.patch.js

Can you try it out... if it works, I'll commit and push a new version to Github.

Let me know.

jamesjh commented 9 years ago

correct me if I am wrong, but the text inside the label should be the the same as the value of the checkbox - except the label text has a leading and trailing whitespace. this excerpt might be more illustrative of what is happening in IE 8:

<LABEL><INPUT class="spwidget-input spwidget-filter-input" title="ImpactedLinesOfBusiness" type="checkbox" name="ImpactedLinesOfBusiness" Loan="" Student="" Finance="" value="Auto" /> Auto Finance / Student Loan </LABEL>

jamesjh commented 9 years ago

so you can see the value is "Auto" instead of "Auto Finance / Student Loan"

purtuga commented 9 years ago

Did you try the updated version I posted in the link above? It should fix this issue, but I want to hear back from you first before I post an official patch.

Also: are you using any other widget?

This problem probably exists in other widgets, but thus far I fixed it in filter panel only.

the problem

The issue here has to do with how IE returns the innerHTML of DOM elements and specifically how it handles attribute values. If the attribute value does not have a space, it is returned without quotes, which is a problem with the HTML template I'm using to build these entries into the panel.

Let me know if the patched version fixes this.

jamesjh commented 9 years ago

yes, it worked:

<LABEL><INPUT class="spwidget-input spwidget-filter-input" title="ImpactedLinesOfBusiness" type="checkbox" name="ImpactedLinesOfBusiness" value="Auto Finance / Student Loan" /> Auto Finance / Student Loan </LABEL>

jamesjh commented 9 years ago

yes, it did produce the desired output:

<LABEL><INPUT class="spwidget-input spwidget-filter-input" title="ImpactedLinesOfBusiness" type="checkbox" name="ImpactedLinesOfBusiness" value="Auto Finance / Student Loan" /> Auto Finance / Student Loan </LABEL>

purtuga commented 9 years ago

Ok... Good... I'll push through the changes to Github later today and will tag it as a patch.

jamesjh commented 9 years ago

I am using Build Date: July 20, 2014 - 04:47 PM Version: 20140720044701 would you be able to help me modify it? In the past I did try to upgrade to a more recent version and it didn't work - visually - with my code.

jamesjh commented 9 years ago

Thanks so much for your timely efforts!

purtuga commented 9 years ago

James, The fix in the version you are using is not as easy as it was in the current version because I was not using AMD modules and had a completely different approach to how widget templates were retrieved.

Is there anyway you can just upgrade to the current version?

I just release a new version - v2.5.1 - with this fix. The compiled library can also be download dist folder - here

You said you have tried, but did not work.. can you clarify? maybe what you experience is something that needs to be fixed as well.

jamesjh commented 9 years ago

Yes, you are correct. I have been able to use the new library just fine. Thanks again for this great project!