Previous day i had a which deals with some no sense.
I was working on a admin panel which is fully made of Bootstrap and rich set of its native date, time picker and its own entities. At the same time for the front / user end panel I was given a paid template from theme forest and it had a loads of features with proper documentation in it.
The guy i was working with wanted to have one of the element (Time Picker) like the below given screen
The only difficulty to have this in admin panel is because of the several conflicts araised from the admin panel, I really don’t have enough time to fix these conflicts (and i am already having multiple jquery functions inside my page). The situation i want to have the feature without disturbing my working within a certain period of time (say 30 min). So i planned to use the (poor) iframe to have that feature.
What i did is i filtered all the css, js files required for the targeted time picker and made a minified version which results in 17 kb ~ . This was not a big deal to load inside a frame,
As a default property of iframe scrolling=”no” frameborder=”0″ and then i wanted to get the frame’s value while submitting as i don’t want to complex to set the value via ajax call on change of the frame’s element.
Then what i did was, i planned to get the value of the frame’s element while submitting by identifying the frame’s name and element’s name.
It is achieved by
var target = $('iframe[name=select_frame]').contents().find('#select_name').val();
In the above code, select_frame is the frame’s name and select_name is the element’s name inside the frame and it was assigned to the variable target inside my frame.
Then i wanted to send all those values to another page by jquery ajax call, if i get each element’s value by id it would not at all a deal, as i already to form serialize i wanted to add this element towards the value of the form to the target page.
So, Here is the simple workaround
data : $("#allocateboat").serialize()+'&element='+target,
What i did is just added the element along the form serialized value and it was done