не работает кнопка
Приветствую всех!
Есть фрейм, в котором нужно отметить геоположения и нажатием кнопки вставить их в окно редактора. Кнопка Insert не работает - в Chrome в development tool пишет после ее нажатия, что страница была крашед... <script type="text/javascript"> var pickerType = "criteria"; //Set initial pick type var pathToAjax = ""; var ButtonDialog = { local_ed : 'ed', init : function(ed) { // ButtonDialog.local_ed = ed; //было закоменчено !!! tinyMCEPopup.resizeToInnerSize(); var catsData = { action: 'get_all_mapcategories' } pathToAjax = (ed['buttons']['maplist']['pluginurl']).replace('wp-content/plugins/map-list-pro/js','/wp-admin/'); //get location categories //jQuery.post(pathToAjax + "admin-ajax.php", catsData, function(response) { jQuery.post("/wp-admin/admin-ajax.php", catsData, function(response) { $('#TypeList').html(response).removeClass('loading'); }); }, insert : function insertButton(ed){ ////Validate the form first var isValid = true; var catString = ""; //Set variables based on picker type if(pickerType == "criteria"){ //Get variables //Checked items var types = jQuery(':checked','#TypeList'); //Make them into a string types.each(function(){ if(catString != ""){ catString += ','; } catString += jQuery(this).val(); }); } else{ //Check to see if a file has been picked if(jQuery('.file:checked').length == 0){ //Error $('#FileError').removeClass('hidden'); isValid = false; } else{ //Is valid catString = "pdf,xls,doc,zip,ppt,img,mp3"; $('#FileError').addClass('hidden'); isValid = true; } } //Quit out if invalid if(isValid == false) { return; } //Get files to display var fileList = ""; $('.file:checked').each(function(){ fileList += $(this).val() + ','; }); var filesPerPage = jQuery('#FilesPerPage').val(); //Get output var ready var output = ''; //Build the output of our shortcode output = '[maplist '; //If criteria based list if(pickerType == "criteria"){ //Add categories output += catString != "" ? 'categories="' + catString + '" ' : ''; } else{ //Add file list output += fileList != "" ? ' locationstoshow="' + fileList + '" ' : ''; } //Show directions output += jQuery('#ShowDirections').val() == "true" ? 'showdirections="true" ' : 'showdirections="false" '; //Add sorting output += jQuery('#DirectionToSortBy').val() != "DESC" ? 'orderdir="' + jQuery('#DirectionToSortBy').val() + '" ' : ""; //Hide buttons output += jQuery('#hidefilter').is(":checked") ? 'hidefilter="true" ' : ""; output += jQuery('#hidesort').is(":checked") ? 'hidesort="true" ' : ""; output += jQuery('#hidesearch').is(":checked") ? 'hidesearch="true" ' : ""; //Open in new window? output += jQuery('#openinnew').is(":checked") ? 'openinnew="true" ' : ""; output += 'locationsperpage="' + filesPerPage + '"]'; // inserts the shortcode into the active editor tinyMCE.activeEditor.execCommand('mceInsertContent', 0, output); // closes Thickbox tinyMCEPopup.close(); } }; tinyMCEPopup.onInit.add(ButtonDialog.init, ButtonDialog); $(document).ready(function(){ //Don't reload everytime var firstLocationView = true; //Make tabs work $('#ShowFilePicker').click(function(){ $('a','#Tabs').removeClass('selected'); $(this).addClass('selected'); $('#PickFiles').show(); $('#PickByCriteria').hide(); pickerType = "file"; if(firstLocationView){ //get attached files var data = { action: 'get_all_maplocations' }; jQuery.post(pathToAjax + "admin-ajax.php", data, function(response) { $('#AllAttachedFiles').html(response).removeClass('loading'); firstLocationView = false; }); } }); $('#ShowCriteriaPicker').click(function(){ $('a','#Tabs').removeClass('selected'); $(this).addClass('selected'); $('#PickFiles').hide(); $('#PickByCriteria').show(); pickerType = "criteria"; }); }); </script> код кнопки <a href="javascript:ButtonDialog.insert(ButtonDialog.local_ed)" id="insert" class="button">Insert</a> Меня смущает то, что вызывается ButtonDialog.local_ed, который на самом деле закоменчен... Но я делал его активным, а результат тот же - результат фрейма в редактор не попадает и браузер предлагает обновить страницу. Может что-то не то я делаю? |
Часовой пояс GMT +3, время: 18:34. |